Fix T47051: cycles viewport textured shadeless draw bug.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 23 Dec 2015 19:38:58 +0000 (20:38 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 23 Dec 2015 19:38:58 +0000 (20:38 +0100)
source/blender/gpu/intern/gpu_basic_shader.c
source/blender/gpu/intern/gpu_draw.c

index 6b01ee85170b03c5391f82be9057bee2a57cd0c1..c441a44c17b600722e93668c9c42bdce7311cd7c 100644 (file)
@@ -205,10 +205,15 @@ void GPU_basic_shader_bind(int options)
                        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
                }
 
-               if (options & GPU_SHADER_TEXTURE_2D)
+               if (options & GPU_SHADER_TEXTURE_2D) {
+                       GLint env_mode = (options & (GPU_SHADER_USE_COLOR|GPU_SHADER_LIGHTING)) ? GL_MODULATE : GL_REPLACE;
                        glEnable(GL_TEXTURE_2D);
-               else if (bound_options & GPU_SHADER_TEXTURE_2D)
+                       glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env_mode);
+               }
+               else if (bound_options & GPU_SHADER_TEXTURE_2D) {
+                       glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
                        glDisable(GL_TEXTURE_2D);
+               }
        }
 
        GPU_MATERIAL_STATE.bound_options = options;
index 05d115496569d5a30db483839d321d4a7570b766..27e428d7f6928b229b144e84324395ec86b02d13 100644 (file)
@@ -2113,6 +2113,7 @@ void GPU_state_init(void)
        glDisable(GL_STENCIL_TEST);
        glDisable(GL_TEXTURE_1D);
        glDisable(GL_TEXTURE_2D);
+       glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 
        /* default disabled, enable should be local per function */
        glDisableClientState(GL_VERTEX_ARRAY);