Confusing camera view definion #6091
Labels
A-Rendering
Drawing game state to the screen
C-Bug
An unexpected or incorrect behavior
C-Code-Quality
A section of code that is hard to understand or change
Bevy version
0.8.1
What you did
I was working on my own camera system for bevy for a couple days and for the last three I got very confused about how does view matrix work in bevy - because many results that I was getting were rather unintuitive to me.
I'm quite new to the source code of bevy, therefore it took me a while to even find the place where camera matrix got uploaded to the uniform buffer, but once I found it, the source of my confusion became quite apparent:
The
view_proj
definition of the uniform buffer loads an inverse of a view matrix here:bevy/crates/bevy_render/src/view/mod.rs
Line 159 in 847c26b
while the
view
part ofViewUniform
actually loads theview
matrix itself. At least one of those should be fixed and ideally naming around it could be clarified.In terms of functionality, I think that view_proj is calculated correctly, but it isn't the inverse of a view matrix there but instead it's the "inverse of global transform on camera" is the view matrix.
And I think that
view
andinverse_view
fields ofViewUniform
are actually populated incorrectly. I've looked at the shaders briefly and didn't see those used anywhere - so it's likely that this bug hasn't manifested itself yet.The text was updated successfully, but these errors were encountered: