From 5d691350c4fc162a0d85369072fd72b8a2bbd1c5 Mon Sep 17 00:00:00 2001 From: elasota Date: Fri, 24 Mar 2017 20:27:06 -0400 Subject: [PATCH] Fixed "unshaded" flag not being updated if light_type and receive_shadows_state didn't change. --- drivers/gles2/rasterizer_gles2.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 94ff103daac..95b8b951a17 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -5971,6 +5971,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list, const Tran RID prev_baked_light_texture; const float *prev_morph_values = NULL; int prev_receive_shadows_state = -1; + int prev_unshaded_state = -1; material_shader.set_conditional(MaterialShaderGLES2::USE_VERTEX_LIGHTING, !shadow && !p_fragment_light); material_shader.set_conditional(MaterialShaderGLES2::USE_FRAGMENT_LIGHTING, !shadow && p_fragment_light); @@ -6006,6 +6007,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list, const Tran const BakedLightData *baked_light = e->instance->baked_light; const float *morph_values = e->instance->morph_values.ptr(); int receive_shadows_state = e->instance->receive_shadows == true ? 1 : 0; + int unshaded_state = (material->flags[VS::MATERIAL_FLAG_UNSHADED] || current_debug == VS::SCENARIO_DEBUG_SHADELESS) ? 1 : 0; bool rebind = false; bool bind_baked_light_octree = false; @@ -6028,15 +6030,16 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list, const Tran prev_sort_flags = 0xFF; prev_morph_values = NULL; prev_receive_shadows_state = -1; + prev_unshaded_state = -1; glEnable(GL_BLEND); glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); } - if (light_type != prev_light_type || receive_shadows_state != prev_receive_shadows_state) { + if (light_type != prev_light_type || receive_shadows_state != prev_receive_shadows_state || unshaded_state != prev_unshaded_state) { - if (material->flags[VS::MATERIAL_FLAG_UNSHADED] || current_debug == VS::SCENARIO_DEBUG_SHADELESS) { + if (unshaded_state == 1) { material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_DIRECTIONAL, false); material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_OMNI, false); material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_SPOT, false); @@ -6385,6 +6388,7 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list, const Tran prev_baked_light = baked_light; prev_morph_values = morph_values; prev_receive_shadows_state = receive_shadows_state; + prev_unshaded_state = unshaded_state; } //print_line("shaderchanges: "+itos(p_alpha_pass)+": "+itos(_rinfo.shader_change_count));