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:
|
view_proj: projection * inverse_view, |
while the view part of ViewUniform actually loads the view 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 and inverse_view fields of ViewUniform 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.
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_projdefinition 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
viewpart ofViewUniformactually loads theviewmatrix 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
viewandinverse_viewfields ofViewUniformare 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.