Merge pull request #96771 from clayjohn/RD-static-lighting

Avoid calculating dynamic lights when lights are already baked using the static bake mode in the Forward+ renderer
This commit is contained in:
Thaddeus Crews 2024-12-10 14:15:41 -06:00
commit a167afd70a
No known key found for this signature in database
GPG key ID: 62181B86FE9E5D84
6 changed files with 40 additions and 28 deletions

View file

@ -2211,6 +2211,10 @@ void fragment_shader(in SceneData scene_data) {
continue; //not masked
}
if (directional_lights.data[i].bake_mode == LIGHT_BAKE_STATIC && bool(instances.data[instance_index].flags & INSTANCE_FLAGS_USE_LIGHTMAP)) {
continue; // Statically baked light and object uses lightmap, skip
}
#ifdef LIGHT_TRANSMITTANCE_USED
float transmittance_z = transmittance_depth;
#ifndef SHADOWS_DISABLED

View file

@ -1445,6 +1445,10 @@ void main() {
continue; //not masked
}
if (directional_lights.data[i].bake_mode == LIGHT_BAKE_STATIC && bool(instances.data[draw_call.instance_index].flags & INSTANCE_FLAGS_USE_LIGHTMAP)) {
continue; // Statically baked light and object uses lightmap, skip.
}
float shadow = 1.0;
if (directional_lights.data[i].shadow_opacity > 0.001) {
@ -1560,6 +1564,10 @@ void main() {
continue; //not masked
}
if (directional_lights.data[i].bake_mode == LIGHT_BAKE_STATIC && bool(instances.data[draw_call.instance_index].flags & INSTANCE_FLAGS_USE_LIGHTMAP)) {
continue; // Statically baked light and object uses lightmap, skip.
}
// We're not doing light transmittence
float shadow = 1.0;

View file

@ -676,12 +676,13 @@ void LightStorage::update_light_buffers(RenderDataRD *p_render_data, const Paged
angular_diameter = 0.0;
}
light_data.bake_mode = light->bake_mode;
if (light_data.shadow_opacity > 0.001) {
RS::LightDirectionalShadowMode smode = light->directional_shadow_mode;
light_data.soft_shadow_scale = light->param[RS::LIGHT_PARAM_SHADOW_BLUR];
light_data.softshadow_angle = angular_diameter;
light_data.bake_mode = light->bake_mode;
if (angular_diameter <= 0.0) {
light_data.soft_shadow_scale *= RendererSceneRenderRD::get_singleton()->directional_shadow_quality_radius_get(); // Only use quality radius for PCF