Skip to content

Initialize light index push constants to 0xFFFFFFFF instead of 0xFFFF#70068

Merged
akien-mga merged 1 commit into
godotengine:masterfrom
clayjohn:mobile-lights
Dec 15, 2022
Merged

Initialize light index push constants to 0xFFFFFFFF instead of 0xFFFF#70068
akien-mga merged 1 commit into
godotengine:masterfrom
clayjohn:mobile-lights

Conversation

@clayjohn

Copy link
Copy Markdown
Member

Fixes: #55881

Each of these push constants is a 32 bit integer used to carry 4 singly byte integers (0-255 range). In the shader, the value of 0xFF is used to check if a light is unused in which case it skips rendering that light. Since we initialized the values to 0xFFFF, the shader would think that the indices are as follows (0, 1, 0, 0) instead of (0, 1, 255, 255). So instead of skipping the last two indices, it just draws the light at index 0 3 times (actually five times because a total of 8 potential lights are used).

This PR should also improve performance as the expensive lighting calculations are now only done as many times as needed.

Before
Screenshot from 2022-12-14 10-34-25

After
Screenshot from 2022-12-14 10-34-46

@clayjohn clayjohn added this to the 4.0 milestone Dec 14, 2022
@clayjohn clayjohn requested a review from a team as a code owner December 14, 2022 18:35
@akien-mga

Copy link
Copy Markdown
Member

A rebase should fix godot-cpp CI.

@clayjohn

Copy link
Copy Markdown
Member Author

A rebase should fix godot-cpp CI.

Done! :)

@akien-mga akien-mga merged commit a194984 into godotengine:master Dec 15, 2022
@akien-mga

Copy link
Copy Markdown
Member

Thanks!

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.

Vulkan Mobile backend: Point lights can appear brighter (duplicated) depending on the camera angle if there is more than one of the same type in view

3 participants