-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement distance fade properties in OmniLight3D and SpotLight3D #58512
Implement distance fade properties in OmniLight3D and SpotLight3D #58512
Conversation
392c118
to
b35bdf1
Compare
This can be used to fade lights and their shadows in the distance, similar to Decal nodes. This can bring significant performance improvements, especially for lights with shadows enabled and when using higher-than-default shadow quality settings. While lights can be smoothly faded out over distance, shadows are currently "all or nothing" since per-light shadow color is no longer customizable in the Vulkan renderer. This may result in noticeable pop-in when leaving the shadow cutoff distance, but depending on the scene, it may not always be that noticeable.
b35bdf1
to
b1a295b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
We have discussed in the past about adding a unified distance fade system for all visual instance types, but I think if this ever happens, it will be a set of properties in VisualInstance
that are handled accordingly on each visual type. That means these changes should be reusable mostly unchanged, and the feature is useful on its own.
@@ -3494,7 +3522,24 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const | |||
|
|||
light_data.attenuation = storage->light_get_param(base, RS::LIGHT_PARAM_ATTENUATION); | |||
|
|||
float energy = sign * storage->light_get_param(base, RS::LIGHT_PARAM_ENERGY) * Math_PI; | |||
// Reuse fade begin, fade length and distance for shadow LOD determination later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this some reference for a future implementation? I don't see anything related to shadow LOD in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Light shadow LOD refers to the shadow cutoff distance, which can be set separately from the light cutoff distance (which is begin + length
). I can reword the comment if it's confusing.
Thanks! |
This can be used to fade lights and their shadows in the distance, similar to Decal nodes. This can bring significant performance improvements, especially for lights with shadows enabled and when using higher-than-default shadow quality settings.
While lights can be smoothly faded out over distance, shadows are currently "all or nothing" since per-light shadow color is no longer customizable in the Vulkan renderer. This may result in noticeable pop-in when leaving the shadow cutoff distance, but depending on the scene, it may not always be that noticeable.
The default values and property hints are identical to #58296. Note that distance fade is still disabled by default (like for Decal), which means the default light rendering behavior is unchanged.
I've tested this PR with VoxelGI, SDFGI and LightmapGI. All techniques still work with distance fade, regardless of the camera position when baking. Lights will still be present in GI rendering even if they are past the distance, but this also helps make light transitions less noticeable, so it's not too bad.
Edit (May 2022): I started working on a
3.x
backport, but didn't manage to get it fully working so far:https://github.com/Calinou/godot/tree/light-add-distance-fade-3.x
This closes godotengine/godot-proposals#2744.
Testing project: test_light_lod.zip
Press L to toggle distance fade for all lights.
Preview
The highest shadow quality settings are used here.
Without distance fade
Lights are never culled regardless of distance. This is the current behavior.
With distance fade
Distant lights are culled, and partially faded lights have their shadows disabled (this is configurable).