From 1815871b902e4bcca5631c166570f364d0885690 Mon Sep 17 00:00:00 2001 From: Oxi <33568643+oxi-dev0@users.noreply.github.com> Date: Fri, 16 Feb 2024 01:13:12 +0000 Subject: [PATCH] Fixed unshaded mode lightmaps --- drivers/gles3/rasterizer_scene_gles3.cpp | 66 +++++++++++-------- .../renderer_rd/renderer_scene_render_rd.cpp | 1 + 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index ecb563214ce..bc1af86938f 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -3112,39 +3112,47 @@ void RasterizerSceneGLES3::_render_list_template(RenderListParameters *p_params, if (pass == 0) { spec_constants |= SceneShaderGLES3::BASE_PASS; - if (inst->omni_light_gl_cache.size() == 0) { + + if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED) { spec_constants |= SceneShaderGLES3::DISABLE_LIGHT_OMNI; - } - - if (inst->spot_light_gl_cache.size() == 0) { spec_constants |= SceneShaderGLES3::DISABLE_LIGHT_SPOT; - } - - if (p_render_data->directional_light_count == p_render_data->directional_shadow_count) { spec_constants |= SceneShaderGLES3::DISABLE_LIGHT_DIRECTIONAL; - } - - if (inst->reflection_probe_rid_cache.size() == 0) { - // We don't have any probes. - spec_constants |= SceneShaderGLES3::DISABLE_REFLECTION_PROBE; - } else if (inst->reflection_probe_rid_cache.size() > 1) { - // We have a second probe. - spec_constants |= SceneShaderGLES3::SECOND_REFLECTION_PROBE; - } - - if (inst->lightmap_instance.is_valid()) { - spec_constants |= SceneShaderGLES3::USE_LIGHTMAP; - - GLES3::LightmapInstance *li = GLES3::LightStorage::get_singleton()->get_lightmap_instance(inst->lightmap_instance); - GLES3::Lightmap *lm = GLES3::LightStorage::get_singleton()->get_lightmap(li->lightmap); - - if (lm->uses_spherical_harmonics) { - spec_constants |= SceneShaderGLES3::USE_SH_LIGHTMAP; - } - } else if (inst->lightmap_sh) { - spec_constants |= SceneShaderGLES3::USE_LIGHTMAP_CAPTURE; - } else { spec_constants |= SceneShaderGLES3::DISABLE_LIGHTMAP; + } else { + if (inst->omni_light_gl_cache.size() == 0) { + spec_constants |= SceneShaderGLES3::DISABLE_LIGHT_OMNI; + } + + if (inst->spot_light_gl_cache.size() == 0) { + spec_constants |= SceneShaderGLES3::DISABLE_LIGHT_SPOT; + } + + if (p_render_data->directional_light_count == p_render_data->directional_shadow_count) { + spec_constants |= SceneShaderGLES3::DISABLE_LIGHT_DIRECTIONAL; + } + + if (inst->reflection_probe_rid_cache.size() == 0) { + // We don't have any probes. + spec_constants |= SceneShaderGLES3::DISABLE_REFLECTION_PROBE; + } else if (inst->reflection_probe_rid_cache.size() > 1) { + // We have a second probe. + spec_constants |= SceneShaderGLES3::SECOND_REFLECTION_PROBE; + } + + if (inst->lightmap_instance.is_valid()) { + spec_constants |= SceneShaderGLES3::USE_LIGHTMAP; + + GLES3::LightmapInstance *li = GLES3::LightStorage::get_singleton()->get_lightmap_instance(inst->lightmap_instance); + GLES3::Lightmap *lm = GLES3::LightStorage::get_singleton()->get_lightmap(li->lightmap); + + if (lm->uses_spherical_harmonics) { + spec_constants |= SceneShaderGLES3::USE_SH_LIGHTMAP; + } + } else if (inst->lightmap_sh) { + spec_constants |= SceneShaderGLES3::USE_LIGHTMAP_CAPTURE; + } else { + spec_constants |= SceneShaderGLES3::DISABLE_LIGHTMAP; + } } } else { // Only base pass uses the radiance map. diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index e61bb9eae82..6cb03871c96 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -1157,6 +1157,7 @@ void RendererSceneRenderRD::render_scene(const Ref &p_render render_data.lights = ∅ render_data.reflection_probes = ∅ render_data.voxel_gi_instances = ∅ + render_data.lightmaps = ∅ } if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED ||