Use separate texture unit for light_texture #42538
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.
Fixes: #42521
This bug has been present since the early stages of the GLES2 renderer. In a366d45 when reduz added the screen_texture he made it share a texture unit with the light texture. I am not sure why. As a result, when lights are drawn over sprites that read from
SCREEN_TEXTURE
, during the fragment pass they read from the light texture instead of the screen texture which results in a weird ghosting artifact.About 30% of GLES2 devices have only 8 texture units so we try to use as few internal texture units as possible. That may be why reduz chose to share light texture and screen texture. This change makes the Godot internal shader take up 6 texture units which leaves the user with only 2 for themselves one these devices.
In light of the above, reduz needs to approve this change himself. It may have been an oversight, but there also may be a legitimate reason to avoid using the 6th texture unit.