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

Fix LightmapGI shading sometimes being unlit or black #81951

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

bitsawer
Copy link
Member

@bitsawer bitsawer commented Sep 19, 2023

Looks like the bitshift by 20 is an old remnant that was never updated, it seems like it should be 16, especially considering other code in the shader file does shift the .gi_offset by 16. Checking the git history seems to confirm this, looks like #44838 forgot to update the value. Seems like this actually worked most of the time, but failed in certain cases and read the wrong index resulting it reading random data. Most of the time the random exposure value was 0.0 or near it, so multiplying by it resulted in black shading.

This seems to fix the shading issues in both Forward and Mobile renderers, but more testing is appreciated. Also thanks to jeffhube for nice analysis: #73124 (comment) which gave a good starting point.

@bitsawer bitsawer added this to the 4.2 milestone Sep 19, 2023
@bitsawer bitsawer requested a review from a team as a code owner September 19, 2023 23:14
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally (rebased on top of master 571cd0e), it works as expected:

image

This fix doesn't require baking lightmaps again to be effective. (I baked lightmaps again to make sure it doesn't break, just in case.)

@Calinou Calinou added the cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release label Sep 20, 2023
@akien-mga akien-mga merged commit 3cce730 into godotengine:master Sep 20, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@bitsawer bitsawer deleted the fix_lightmap_shader_indexing branch September 20, 2023 18:22
@YuriSizov
Copy link
Contributor

Cherry-picked for 4.1.3.

@YuriSizov YuriSizov removed the cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release label Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LightmapGI: Some meshes become completely unlit or black when baking lightmaps
4 participants