Fix LightmapGI shading sometimes being unlit or black #81951
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.