Skip to content

Always send lights to sky shader if using sun scatter #107928

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

Merged
merged 1 commit into from
Jun 24, 2025

Conversation

Kaleb-Reid
Copy link
Contributor

@Kaleb-Reid Kaleb-Reid commented Jun 24, 2025

Currently sun scatter isn't applied to the sky properly if the sky shader doesn't contain any LIGHTX_* built-ins.

Fixes #107924.

@Kaleb-Reid Kaleb-Reid requested a review from a team as a code owner June 24, 2025 08:20
@AThousandShips AThousandShips added bug topic:rendering topic:3d cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release labels Jun 24, 2025
@AThousandShips AThousandShips added this to the 4.5 milestone Jun 24, 2025
@clayjohn
Copy link
Member

Do you know why this isn't needed with the compatibility renderer? the code appears to be the same

@Kaleb-Reid
Copy link
Contributor Author

Kaleb-Reid commented Jun 24, 2025

@clayjohn I actually went back and tested again and you're right to question why this doesn't happen in Compatibility because it does have a similar problem which I've now fixed.

if (shader_data->uses_light) {
sky_globals.directional_light_count = 0;

In the Compatibility renderer the light count only gets set to 0 in the sky if the shader uses any of the LIGHTX_* built-ins, so if you add a light while you have a sky which uses them and then remove all of the built-ins the sun scatter stays but does not update if you modify the lights.

Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@Kaleb-Reid
Copy link
Contributor Author

@clayjohn I made a minor change: updating the lights solely for sun scatter should probably also check if fog is enabled. I'm not sure if you need to approve this again or how that side of things works.

@clayjohn
Copy link
Member

Thanks for letting me know. I usually approve again in these situations.

@Repiteo Repiteo merged commit 0564019 into godotengine:master Jun 24, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jun 24, 2025

Thanks!

@Kaleb-Reid Kaleb-Reid deleted the scatter-no-LIGHTX branch June 25, 2025 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release topic:rendering topic:3d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fog sun scatter doesn't work without LIGHTX_* in sky shader
4 participants