Add priority setting to reflection probes
This PR adds a priority setting to reflection probes.
This is to solve the scenario where probes overlap but where we do not want to apply blending but choose the most appropriate probe.
In this screenshot we have setup the Sponza demo with a reflection probe spanning the entire center so we get a reflection on the floor, and a probe centered on the sphere to get a nice reflection on the sphere:
As the two reflection probes overlap for the sphere, we see them blended resulting in an ugly reflection. Now this simple scenario can be solved with setting masks however in more complex scenarios that is not an option.
With this PR we can increase the priority of the reflection probe for the sphere so that it is used for anything inside of its AABB:
This works on fragment level. The probe with the highest priority is used. If multiple probes match the highest priority, they are blended as before.
- Production edit: This closes https://github.com/godotengine/godot-proposals/issues/8167.
The property is here:
Consider that Godot uses the term xyz_priority_xyz for similar rankings all over the place. Not a single use of importance.
Consider that Godot uses the term
xyz_priority_xyzfor similar rankings all over the place. Not a single use ofimportance.
Yeah I'm not sure why importance became the term named in discussing this a few weeks ago.
I'm not married to the name so more than happy to change it.
I agree that Priority is conceptually a better fit, too.
@BastiaanOlij works as intended. I wonder if it will work with this to blend the edge of probes.
https://github.com/godotengine/godot/pull/61416
Ok, I've renamed it to priority.
Well, its correct on my branch, but it's not synching up with the PR?!?
edit seems to be an issue with github
Looks like it synched up now :)
Something I don't understand. If you don't want the sphere to use other probes and you don't want the probe for the sphere to be used to others, why not simply mask them away?
EDIT: Oh okay I saw the explanation in the linked issue, makes full sense.
Something I don't understand. If you don't want the sphere to use other probes and you don't want the probe for the sphere to be used to others, why not simply mask them away?
Lol, I even mentioned it in my original post :P
Now this simple scenario can be solved with setting masks however in more complex scenarios that is not an option.
But I do think it's a valid concern, a lot of scenarios good usage of masks will be superior in preventing overhead compared to using priority. But as the original issue states, there are various use cases where masks won't cut it and the decision has to be made on fragment level.
I do think that the approach I took should have little to no impact on performance especially if priority remains unused and basically the same amount of work is performed.
One improvement I can think of is to order the probes from highest priority to lowest somehow so probes are more likely to be skipped when they have a lower priority. But I'm not sure how we could make that happen, that might be something that needs to be done in the clustering?
@clayjohn Could be this on 4.4?
@BastiaanOlij Is there a way to blend the edge of probes with different priorities?
Enhancements are on 4.x until they've been approved as they have no specific schedule, unless specifically prioritised, but it makes little difference as features are reviewed and approved as people are able
Note that since https://github.com/godotengine/godot/pull/88056 was merged, this PR should be amended to support the feature in the Compatibility rendering method. Alternatively, if this is not technically feasible, the limitation should be documented.
Considering UX, I'm wondering how necessary it is for the priority to be an exposed setting to the user. I'm not sure I can really imagine a use case where you would need to have manual control over this. Requiring an artist to manage this manually introduces a not insignificant time cost, especially in more complex/higher fidelity scenes where it is likely you have a probe structure with several layers. To me this seems like an unnecessary workflow impediment compared to auto-priority.
I would suggest Unreals approach: They tackle this issue by sorting priority automatically based on the size of a probe, where smaller sizes take higher priority than larger sizes, and equal sizes take equal priority. This approach makes sense because setting a smaller probe to a lower priority than the larger probe it is within just makes the reflections of the smaller probe invisible.
If at all, blending the reflections of two probes could be implemented as a checkbox which decreases the priority by 1 when checked. Though, even there I'm not sure in what situation you'd ever want that behavior: Doing this introduces duplicated reflections (example from https://github.com/godotengine/godot/pull/61416#issuecomment-2503764846):
Normally you'd want whatever is inside a reflection probes bounds to be affected entirely by that reflection probe. E.g. a large room with a metal statue in the corner would require a setup where you have one main probe for the entire room, and then one smaller "detailing" probe on the statue. You don't want the statue to still take reflections of the main room, because you have a probe capturing reflections from a point of view that's much more representative of the statue, and I can't imagine a situation where you would because doing so results in the example above.
Here's an example of what a typical probe setup looks like(represented with circles, but the principle is entirely the same for boxes)
1 - General probe, covering potential gaps or far away areas not covered by smaller probes, lowest priority
2 - More specific, center of a large room
3 - corners and/or nooks
4 - detail probes for things that simply require more accurate reflections (e.g. the metal statue example), highest priority
In this case there are 4 "layers", however, depending on the environment and needs this can be more or less.
Superseded by #100241.