Ver Fonte

Fixed unshaded mode lightmaps

Oxi há 1 ano atrás
pai
commit
1815871b90

+ 33 - 25
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) {
-						spec_constants |= SceneShaderGLES3::DISABLE_LIGHT_OMNI;
-					}
 
-					if (inst->spot_light_gl_cache.size() == 0) {
+					if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
+						spec_constants |= SceneShaderGLES3::DISABLE_LIGHT_OMNI;
 						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;
-					}
+						spec_constants |= SceneShaderGLES3::DISABLE_LIGHTMAP;
+					} else {
+						if (inst->omni_light_gl_cache.size() == 0) {
+							spec_constants |= SceneShaderGLES3::DISABLE_LIGHT_OMNI;
+						}
 
-					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->spot_light_gl_cache.size() == 0) {
+							spec_constants |= SceneShaderGLES3::DISABLE_LIGHT_SPOT;
+						}
 
-					if (inst->lightmap_instance.is_valid()) {
-						spec_constants |= SceneShaderGLES3::USE_LIGHTMAP;
+						if (p_render_data->directional_light_count == p_render_data->directional_shadow_count) {
+							spec_constants |= SceneShaderGLES3::DISABLE_LIGHT_DIRECTIONAL;
+						}
 
-						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 (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 (lm->uses_spherical_harmonics) {
-							spec_constants |= SceneShaderGLES3::USE_SH_LIGHTMAP;
+						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->lightmap_sh) {
-						spec_constants |= SceneShaderGLES3::USE_LIGHTMAP_CAPTURE;
-					} else {
-						spec_constants |= SceneShaderGLES3::DISABLE_LIGHTMAP;
 					}
 				} else {
 					// Only base pass uses the radiance map.

+ 1 - 0
servers/rendering/renderer_rd/renderer_scene_render_rd.cpp

@@ -1157,6 +1157,7 @@ void RendererSceneRenderRD::render_scene(const Ref<RenderSceneBuffers> &p_render
 		render_data.lights = &empty;
 		render_data.reflection_probes = &empty;
 		render_data.voxel_gi_instances = &empty;
+		render_data.lightmaps = &empty;
 	}
 
 	if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED ||