Skip to content

Commit 1d1faa9

Browse files
committed
Merge pull request godotengine#99136 from DarioSamo/light-compute-attenuation-skip
Improve performance of shader lighting code in Forward renderers.
2 parents fc36f39 + f6cb07d commit 1d1faa9

3 files changed

Lines changed: 211 additions & 269 deletions

File tree

servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered.glsl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,11 +2369,7 @@ void fragment_shader(in SceneData scene_data) {
23692369
continue; // Statically baked light and object uses lightmap, skip
23702370
}
23712371

2372-
float shadow = light_process_omni_shadow(light_index, vertex, normal, scene_data.taa_frame_count);
2373-
2374-
shadow = blur_shadow(shadow);
2375-
2376-
light_process_omni(light_index, vertex, view, normal, vertex_ddx, vertex_ddy, f0, orms, shadow, albedo, alpha, screen_uv,
2372+
light_process_omni(light_index, vertex, view, normal, vertex_ddx, vertex_ddy, f0, orms, scene_data.taa_frame_count, albedo, alpha, screen_uv,
23772373
#ifdef LIGHT_BACKLIGHT_USED
23782374
backlight,
23792375
#endif
@@ -2441,11 +2437,7 @@ void fragment_shader(in SceneData scene_data) {
24412437
continue; // Statically baked light and object uses lightmap, skip
24422438
}
24432439

2444-
float shadow = light_process_spot_shadow(light_index, vertex, normal, scene_data.taa_frame_count);
2445-
2446-
shadow = blur_shadow(shadow);
2447-
2448-
light_process_spot(light_index, vertex, view, normal, vertex_ddx, vertex_ddy, f0, orms, shadow, albedo, alpha, screen_uv,
2440+
light_process_spot(light_index, vertex, view, normal, vertex_ddx, vertex_ddy, f0, orms, scene_data.taa_frame_count, albedo, alpha, screen_uv,
24492441
#ifdef LIGHT_BACKLIGHT_USED
24502442
backlight,
24512443
#endif

servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile.glsl

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,13 +1624,7 @@ void main() {
16241624
uvec2 omni_indices = instances.data[draw_call.instance_index].omni_lights;
16251625
for (uint i = 0; i < sc_omni_lights(); i++) {
16261626
uint light_index = (i > 3) ? ((omni_indices.y >> ((i - 4) * 8)) & 0xFF) : ((omni_indices.x >> (i * 8)) & 0xFF);
1627-
1628-
float shadow = light_process_omni_shadow(light_index, vertex, normal, scene_data.taa_frame_count);
1629-
1630-
shadow = blur_shadow(shadow);
1631-
1632-
// Fragment lighting
1633-
light_process_omni(light_index, vertex, view, normal, vertex_ddx, vertex_ddy, f0, orms, shadow, albedo, alpha, screen_uv,
1627+
light_process_omni(light_index, vertex, view, normal, vertex_ddx, vertex_ddy, f0, orms, scene_data.taa_frame_count, albedo, alpha, screen_uv,
16341628
#ifdef LIGHT_BACKLIGHT_USED
16351629
backlight,
16361630
#endif
@@ -1658,12 +1652,7 @@ void main() {
16581652
uvec2 spot_indices = instances.data[draw_call.instance_index].spot_lights;
16591653
for (uint i = 0; i < sc_spot_lights(); i++) {
16601654
uint light_index = (i > 3) ? ((spot_indices.y >> ((i - 4) * 8)) & 0xFF) : ((spot_indices.x >> (i * 8)) & 0xFF);
1661-
1662-
float shadow = light_process_spot_shadow(light_index, vertex, normal, scene_data.taa_frame_count);
1663-
1664-
shadow = blur_shadow(shadow);
1665-
1666-
light_process_spot(light_index, vertex, view, normal, vertex_ddx, vertex_ddy, f0, orms, shadow, albedo, alpha, screen_uv,
1655+
light_process_spot(light_index, vertex, view, normal, vertex_ddx, vertex_ddy, f0, orms, scene_data.taa_frame_count, albedo, alpha, screen_uv,
16671656
#ifdef LIGHT_BACKLIGHT_USED
16681657
backlight,
16691658
#endif

0 commit comments

Comments
 (0)