Commit: 28ea3f5b94175edcfd27612cf56d69106879d9a4
Author: Antony Riakiotakis
Date:   Fri May 1 12:06:05 2015 +0200
Branches: master
https://developer.blender.org/rB28ea3f5b94175edcfd27612cf56d69106879d9a4

Fix T44565 World background artifacts when world shader is void (or
compilation fails).

===================================================================

M       source/blender/editors/space_view3d/view3d_draw.c
M       source/blender/gpu/GPU_material.h
M       source/blender/gpu/intern/gpu_material.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_draw.c 
b/source/blender/editors/space_view3d/view3d_draw.c
index c5fccc8..da628c3 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2940,21 +2940,41 @@ static void view3d_main_area_clear(Scene *scene, View3D 
*v3d, ARegion *ar)
                if (glsl) {
                        RegionView3D *rv3d = ar->regiondata;
                        GPUMaterial *gpumat = GPU_material_world(scene, 
scene->world);
+                       bool material_not_bound;
 
                        /* calculate full shader for background */
                        GPU_material_bind(gpumat, 1, 1, 1.0, false, 
rv3d->viewmat, rv3d->viewinv, rv3d->viewcamtexcofac, (v3d->scenelock != 0));
                        
+                       material_not_bound = !GPU_material_bound(gpumat);
+
+                       if (material_not_bound) {
+                               glMatrixMode(GL_PROJECTION);
+                               glPushMatrix();
+                               glLoadIdentity();
+                               glMatrixMode(GL_MODELVIEW);
+                               glPushMatrix();
+                               glLoadIdentity();
+                               glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
+                       }
+
                        glEnable(GL_DEPTH_TEST);
                        glDepthFunc(GL_ALWAYS);
                        glShadeModel(GL_SMOOTH);
-                       glBegin(GL_QUADS);
+                       glBegin(GL_TRIANGLE_STRIP);
                        glVertex3f(-1.0, -1.0, 1.0);
                        glVertex3f(1.0, -1.0, 1.0);
-                       glVertex3f(1.0, 1.0, 1.0);
                        glVertex3f(-1.0, 1.0, 1.0);
+                       glVertex3f(1.0, 1.0, 1.0);
                        glEnd();
                        glShadeModel(GL_FLAT);
 
+                       if (material_not_bound) {
+                               glMatrixMode(GL_PROJECTION);
+                               glPopMatrix();
+                               glMatrixMode(GL_MODELVIEW);
+                               glPopMatrix();
+                       }
+
                        GPU_material_unbind(gpumat);
                        
                        glDepthFunc(GL_LEQUAL);
diff --git a/source/blender/gpu/GPU_material.h 
b/source/blender/gpu/GPU_material.h
index b61bdf9..7bb044a 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -186,7 +186,7 @@ bool GPU_lamp_override_visible(GPULamp *lamp, struct 
SceneRenderLayer *srl, stru
 void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double 
time, int mipmap, float viewmat[4][4], float viewinv[4][4], float 
cameraborder[4], bool scenelock);
 void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[4][4], 
float obcol[4], float autobumpscale);
 void GPU_material_unbind(GPUMaterial *material);
-int GPU_material_bound(GPUMaterial *material);
+bool GPU_material_bound(GPUMaterial *material);
 struct Scene *GPU_material_scene(GPUMaterial *material);
 GPUMatType GPU_Material_get_type(GPUMaterial *material);
 
diff --git a/source/blender/gpu/intern/gpu_material.c 
b/source/blender/gpu/intern/gpu_material.c
index 4d46ef3..12672b5 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -102,7 +102,6 @@ struct GPUMaterial {
        /* for binding the material */
        GPUPass *pass;
        GPUVertexAttribs attribs;
-       int bound;
        int builtins;
        int alpha, obcolalpha;
        int dynproperty;
@@ -114,6 +113,7 @@ struct GPUMaterial {
        int cameratexcofacloc;
 
        ListBase lamps;
+       bool bound;
 };
 
 struct GPULamp {
@@ -400,7 +400,7 @@ void GPU_material_unbind(GPUMaterial *material)
        }
 }
 
-int GPU_material_bound(GPUMaterial *material)
+bool GPU_material_bound(GPUMaterial *material)
 {
        return material->bound;
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to