Open sleirsgoevy opened 2 years ago
use gbufferModelViewInverse * gl_ModelViewMatrix * gl_Vertex
to get player space (centered at the player)
if you want world space add cameraPosition
if you have further questions you can ask them in the shaderLABS discord https://discord.gg/RpzWN9S
Thanks for the solution, will check if it actually works.
And does that mean that to get actual yaw/pitch I have to do trigonometry on the inverse matrix coefficients?
And does that mean that to get actual yaw/pitch I have to do trigonometry on the inverse matrix coefficients?
no idea, never have done that.
For the blocks themselves, gl_Vertex contains the world coordinates directly, gl_ModelViewMatrix translates them into player-relative coordinates, and gl_ProjectionMatrix translates them into the OpenGL coordinates.
For entities however, gl_Vertex is relative to the entity model, and gl_ModelViewMatrix translates it straight into player-relative coordinates. It also seems to be impossible to reconstruct the world coordinates from those, as the player's yaw/pitch are not exported to shaders.
Please make some feature to get vertices' world coordinates from shader code.