-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Skip rendering sky if viewport is set to transparent background #91642
Skip rendering sky if viewport is set to transparent background #91642
Conversation
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.
We may want to disable updating the radiance maps when the reflection source is not background.
Right now, this will continue to update the radiance maps as long as the background mode is set to sky, even if the reflection mode is set to custom color.
The current logic for updating the radiance maps is:
if (draw_sky || draw_sky_fog_only || environment_get_reflection_source(p_render_data->environment) == RS::ENV_REFLECTION_SOURCE_SKY || environment_get_ambient_source(p_render_data->environment) == RS::ENV_AMBIENT_SOURCE_SKY) {
2976c10
to
fec5d57
Compare
@clayjohn I've changed the logic so The radiance map will thus not be updated when the background is transparent unless:
Hopefully that will give the right level of control. |
fec5d57
to
6efaaec
Compare
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
Show resolved
Hide resolved
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 good to me!
Thanks! |
In Godot 3, if we set the viewport to have a transparent background we would clear the environment used for that viewport skipping rendering things like the sky.
In Godot 4 we no longer do this as many settings in the environment still apply. However as we render the sky with alpha 0 (at least on Vulkan), the user was blissfully unaware the sky was being rendered and this took up a fair bit of resources.
This is because we're (ab)using the alpha for sub surface scattering.
The compatibility renderer doesn't do this and you do see the sky, which at least informs the user they may wish to reconfigure the background. This is something we may change in the future but we'll do that as a separate thing.
This PR resolves this issue by skipping rendering the sky if our viewport is set to transparent. We do still update the radiance map so you can have the sky contribute to ambient lighting.
Test project:
test-transparent-sky.zip