Skip to content
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

Add a level of detail system for ReflectionProbe #2784

Open
Tracked by #66628
Calinou opened this issue May 26, 2021 · 1 comment · May be fixed by godotengine/godot#67465
Open
Tracked by #66628

Add a level of detail system for ReflectionProbe #2784

Calinou opened this issue May 26, 2021 · 1 comment · May be fixed by godotengine/godot#67465

Comments

@Calinou
Copy link
Member

Calinou commented May 26, 2021

See also #2743 which is for particle nodes and #2744 for point lights.

Describe the project you are working on

The Godot editor 🙂

Describe the problem or limitation you are having in your project

Reflection probes currently don't feature a built-in LOD system.1

When you use many reflection probes, these can have a significant performance impact despite them being barely visible when they're in the distance. This is especially true with real-time reflection probes (update mode set to Always).

While Godot 4.0's clustered forward renderer makes it possible to use hundreds of reflection probes while keeping good performance, real-time reflection probes are still relatively expensive in comparison. Also, on low-end/mobile hardware, the mobile renderer can't display hundreds of reflection probes with good performance.

Even when using the default Once update mode, reflection probes can take a while to be rendered if you use dozens of them in a large scene (they're rendered in a seemingly random order). Adding a LOD system would allow for better prioritization of the probes to render first.

For the record, the Decal node (new in 4.0) features a built-in LOD system with configurable distance and fade distance.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Unfortunately, ReflectionProbe doesn't have any built-in way to fade it out progressively. Decreasing the Intensity property will make environment lighting darker, which means it's not usable for progressively fading out the reflection probe. Therefore, the only way to hide distant probes is hide the node.

Alternatively, the Intensity property can be set to 0, which disables reflections but keeps ambient lighting (either from the environment or a constant color configured by the user). This won't improve performance as much as hiding the node, but it still helps a bit while making pop-ins less noticeable.

To get smooth fade-ins, we'll have to tweak the Intensity property not to darken environment lighting when set to values below 1. (The current behavior may be a bug.)
Decreasing Intensity also won't affect environment lighting intensity, but this may be done by design (so that you can create fake area lights that don't affect reflections).

In this bug report, I included a MRP which may be useful for experimentation purposes.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Add the following properties to ReflectionProbe:

  • Lod Distance: The distance at which the reflection probe starts fading away.
  • Lod Fade: The distance over which the reflection probe should be faded.
    • Once the reflection probe is fully faded, it is disabled, resulting in increased performance.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Kind of. It's possible to play with reflection probe intensity and visibility with a script, but see the caveats above.

Is there a reason why this should be core and not an add-on in the asset library?

Implementing this LOD system in C++ would lead to better performance when using large amounts of reflection probes (hundreds or more).

Footnotes

  1. ReflectionProbe already has a Lod Threshold property, but that property is about selecting the automatic mesh LOD level to use when rendering the reflection probe. Lod Threshold does not affect reflection probe visibility at a distance.

@Calinou
Copy link
Member Author

Calinou commented Feb 25, 2022

I have a WIP branch implementing this: https://github.com/Calinou/godot/tree/reflectionprobe-add-distance-fade

Testing project (for the above branch only): test_reflection_probe_distance_fade.zip

It does give the expected performance benefits. However, reflection probes currently don't fade with background sky reflections properly, and their ambient lighting is also not modulated by the Intensity property. Both need to be fixed before distance fading can look correct. I'll look into doing that in a separate PR.

Edit: I started looking into fixing intensity blending, but didn't succeed yet: https://github.com/Calinou/godot/tree/reflectionprobe-fix-intensity-blending

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant