-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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 Specular Occlusion to meshes under influence of LightmapGI #86102
base: master
Are you sure you want to change the base?
Add Specular Occlusion to meshes under influence of LightmapGI #86102
Conversation
I test it. Works incredible well. The results are more realistic and works awesome with reflection probes |
They come from the middle of the bottom cube! |
fee4aa8
to
2a7a454
Compare
Is this a feature that makes sense to add to the compatibility renderer too? Now that PR #85120 is merged, |
Compatibility support has been added 🙂
|
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.
I think this looks amazing! Great work.
My only concern is over whether we need two render modes for this. We try to keep options simple as possible.
Looking at the code, the conservative mode only adds a couple of instructions and it appears to be the more "correct" looking option. Would it make sense to only expose one render mode for specular occlusion and have it apply the current "conservative" option?
Basically, is there a situation where the non-conservative option is preferred other than just being slightly less costly?
I didn't get what you suggest. Also I found the |
@clayjohn
But "conservative" is the best one when there are enough source of reflections in darker areas.
So as shown in the table, if you choose conservative and don't have any possibility for another reflection then it will look too much blown out. But enabling SDFGI here make conservative the best choice. I'm not really sure what to do if we're going for one setting as it would mostly force realistic art styles, maybe going for a mix of both? Or a way to keep both but make it simpler but how? |
Can we expose the Default/Conservative/Disabled option as a project setting rather than a render mode? As I understand it, you probably won't need to use both modes at the same time in the same project, and probably don't need to change it at runtime either. This should allow having only a single render mode and avoiding an increase in the number of shader permutations or VGPR usage. |
Could be a Lightmap property (this is the first place I look at it) |
It has been moved to a project settings. For now modifying the value require a restart. |
9dba392
to
4b39a9e
Compare
A few things...
|
See #50601. This only affects AO maps and SSAO though, not lightmaps. |
To what it's considered dark depends on what the camera see on the lightmapped object so it takes the current exposure in account. Having it as an user-adjustable value would complicate it even further and may introduce a slight cost of performance¹ (and this effect is intended to be cheap and used on mobile and low-end PCs, if you need a correct look you need to use directional lightmaps).
For the conservative part, I'm not really sure how it's less explicit as it's an approximation of what Blender Cycles does, you can see a quick comparison between blender and godot here:
Note: You really need good reflection sources for interior scenes and sometime reflection probes may not work as expected (like in the last row with roughness set to 0); that's where #86135 will help. ¹ If there will be a need for one in the future, there could be a |
In my brief tests this works spectacularly well. Would be interesting to see a slider to adjust how much specular occlusion is present, or to have it tied to an individual material rather than the whole scene (if you've ever used Silent's Filamented Shader in Unity, it's a really great example of offering artistic options for this technique). I understand there may be some limitations to those options though. |
aa17332
to
73dcf1a
Compare
73dcf1a
to
a636046
Compare
(Moved from #86135) After playing with this PR + #86135 for some time, I don't think doing the occlusion based on indirect lighting lightmap is a good idea. There's the obvious issue with differences between static & dynamic lights, but also scenarios where this won't look accurate. One of those scenarios would be a dimly lit room with window(s) to the outside: The reflections here are not correct. Here is how it looks with only SDFGI: Maybe we should bake a sort of "occlusion map" instead? |
@atirut-w Specular occlusion as it's implemented here doesn't seem to handle high dynamic range very well, so having areas of great contrast will mean that too little or too much is being occluded. It would be best to keep scene lighting at a fairly constant brightness when using this technique. This technique is fine and needed. It's not very physically accurate but lends much improvement to lightmapped reflections at little cost. Baking out a scene-wide ambient occlusion map might help in instances that a higher dynamic range is needed at the cost of memory footprint, but I don't think it should be used instead. A slider to adjust what Godot considers dark enough to occlude, PLUS the ability to use a scene-wide AO bake instead of the normal lightmap if desired would probably be best. |
For a greater control, I think it would be better to have a better support for it in custom shaders (but it's out of scope for this PR?), like how the void lightmap() {
DIFFUSE_LIGHT += LIGHTMAP_COLOR * LIGHTMAP_EXPOSURE;
SPECULAR_LIGHT *= length(LIGHTMAP_COLOR) * LIGHTMAP_EXPOSURE;
} The problem with that is that there needs to be a lot of stuff exposed for it; and it also needs to work for directional lightmaps, probes and should work with #86135 ... For a simple slider, while it can be exposed in the LightmapGI node I'm not sure if I could instead expose it in the material shader (eg: |
Having it as a per-material setting that's exposed in StandardMaterial and custom shaders (whether they be node or code-based) would be ideal, definitely. Sometimes you want to control how each independent material handles specular occlusion, and it also allows for a different setting on duplicate materials that are used in darker areas to overcome high dynamic range issues. |
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.
Tested locally (rebased against master
17e7f85), it works as expected. This is a great visual improvement 🙂
Example with a reflection probe:
Closes godotengine/godot-proposals#8637
This pull request implement specular occlusion which reduce the specular light of objects under a lightmap.
It offers two methods and an option to disable it in the project settings:
metallic=1.0 && roughness=0.0
).Which one to choose?
Reduce
at first, while it doesn't give a correct result especially with high reflective materials it's gonna be better than having it reflect the sky while fully occluded.Conservative
when your materials are well setup (such as having correct PBR textures) and a good scene that has good overall reflection sources (either from reflection probes or with GI reflections).Disabled
if you want your metallic and shiny materials to act the same as before or if you want a specific art style.Specular occlusions mixes well and improves:
It support both Forward+, Mobile and Compatibility renderers.
To get started using it, you just need to open an existing scene with my changes and it should work out of the box. Of course if you used materials that act on the specular light (metallic, roughness, specular...) you may need to make some small modifications on them.
Screenshots and Comparisons
Custom Scene
A scene I'll provide later once I'll fix some meshes issues (and improving the textures)
Reduce
Conservative
Japanese Street
Link: https://sketchfab.com/3d-models/japanese-street-at-night-fb1bdcd71a5544d699379d2d13dd1171
On this one,
Conservative
has less impact since a majority of the textures aren't metallic and reflective enough.Reduce
Conservative
Box
Note: A fully reflective material on
Conservative
can still be 100% darkened, it's not happening here because it's not dark enoughmetallic=0
metallic=1
metallic=1 roughness=0 reduce
metallic=1 roughness=0 conservative
Influences by lightmap probes
Characters from: https://github.com/gdquest-demos/godot-4-3D-Characters
The scene used here isn't a good one to compare
metallic=1 roughness=0
Reduce
Conservative
metallic=1 roughness=1
Reduce
Conservative
Dynamic objects on the first scene:
(note: probes seems to have issue outside of this PR in Physical Lights mode, I disabled it here which is why it may look different)
Problems
Dynamic lights and dynamic objects will not have a correct specular occlusion as it will be a bit darker. It can be boosted in the code but I just need to find the correct value so that it look good enough. Otherwise you can either reduce metallic or use the `Conservative` method to boost it. Reason is that the lightmapper seems to darken the lightmap a little bit when in dynamic mode.