fixed spotlight shadow issue due to incorrect basis reconstruction#24238
Open
JeroenHoogers wants to merge 2 commits into
Open
fixed spotlight shadow issue due to incorrect basis reconstruction#24238JeroenHoogers wants to merge 2 commits into
JeroenHoogers wants to merge 2 commits into
Conversation
mockersf
approved these changes
May 10, 2026
kfc35
reviewed
May 10, 2026
| // the construction of the up and right vectors needs to precisely mirror the code | ||
| // in render/light.rs:spot_light_view_matrix | ||
| // in light/spot_light.rs:orthonormalize | ||
| var sign = -1.0; |
Contributor
There was a problem hiding this comment.
might be a dumb question, but is there a reason why this can't delegate to orthonormalize in bevy_render::maths? to reduce on the number of places that this logic should be kept in sync. that function also has a reference to spot_light.rs as well
https://github.com/bevyengine/bevy/blob/main/crates/bevy_render/src/maths.wgsl#L72-L87
Contributor
Author
There was a problem hiding this comment.
Great suggestion, thank you! I was not aware of this function's existence. Definitely looks like a cleaner solution to just call this instead.
…s::orthonormalize()
kfc35
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Objective
Fixes #24232
Solution
The basis vector construction code in the shader was no longer in sync with the rust code. I updated the shader to match the rust code:
bevy/crates/bevy_light/src/spot_light.rs
Lines 172 to 183 in 2002a18
Testing
Run the example code posted in #24232
Showcase
Before:

After: