From 6651336a8a05690b05008fc352e23ee9897adccf Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 7 Sep 2019 14:56:13 -0300 Subject: [PATCH] Directional light cleanup. --- .../visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp | 6 +++--- servers/visual/rasterizer_rd/shaders/scene_forward.glsl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp index 44a5f5f9068..58e8e688d65 100644 --- a/servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp @@ -1432,7 +1432,7 @@ void RasterizerSceneForwardRD::_setup_lights(RID *p_light_cull_result, int p_lig } float fade_start = storage->light_get_param(base, VS::LIGHT_PARAM_SHADOW_FADE_START); - light_data.fade_from = -light_data.shadow_split_offsets[3] * MIN(fade_start, 0.999); + light_data.fade_from = -light_data.shadow_split_offsets[3] * MIN(fade_start, 0.999); //using 1.0 would break smoothstep light_data.fade_to = -light_data.shadow_split_offsets[3]; } @@ -2159,7 +2159,7 @@ void RasterizerSceneForwardRD::_render_scene(RenderBufferData *p_buffer_data, co } } - if (true) { + if (false) { if (directional_shadow_get_texture().is_valid()) { RID shadow_atlas_texture = directional_shadow_get_texture(); Size2 rtsize = storage->render_target_get_size(render_buffer->render_target); @@ -2460,7 +2460,7 @@ RasterizerSceneForwardRD::RasterizerSceneForwardRD(RasterizerStorageRD *p_storag scene_state.light_buffer = RD::get_singleton()->uniform_buffer_create(light_buffer_size); defines += "\n#define MAX_LIGHT_DATA_STRUCTS " + itos(scene_state.max_lights) + "\n"; - scene_state.max_directional_lights = 4; + scene_state.max_directional_lights = 8; uint32_t directional_light_buffer_size = scene_state.max_directional_lights * sizeof(DirectionalLightData); scene_state.directional_lights = memnew_arr(DirectionalLightData, scene_state.max_directional_lights); scene_state.directional_light_buffer = RD::get_singleton()->uniform_buffer_create(directional_light_buffer_size); diff --git a/servers/visual/rasterizer_rd/shaders/scene_forward.glsl b/servers/visual/rasterizer_rd/shaders/scene_forward.glsl index 37919566a54..1bed9f9672a 100644 --- a/servers/visual/rasterizer_rd/shaders/scene_forward.glsl +++ b/servers/visual/rasterizer_rd/shaders/scene_forward.glsl @@ -1190,7 +1190,7 @@ FRAGMENT_SHADER_CODE shadow = mix(shadow,1.0,smoothstep(directional_lights.data[i].fade_from,directional_lights.data[i].fade_to,vertex.z)); //done with negative values for performance - light_attenuation = vec3(shadow); //mix(directional_lights.data[i].shadow_color, vec3(1.0), shadow); + light_attenuation = mix(directional_lights.data[i].shadow_color, vec3(1.0), shadow); }