I'm wondering how I can get the final position of a vertex. I use glTranslate in my render code, and I'm not getting the world-coordinates correct. My world is devided in chunks and my position get's screwed up.

I have tried multiplying the position with the 3 built-in matrices, but no success.

  • \$\begingroup\$ Sorry, I ment glTranslate ofcourse. I edited the post. \$\endgroup\$ – Basaa May 23 '13 at 20:08
  • \$\begingroup\$ The thing is, that I use voxel chunks in my world. In the render code for each chunk, I use glTranslatef to translate the chunk-coordinates to world-coordinates. But, in my shader I now want to use the world-coordinate. \$\endgroup\$ – Basaa May 23 '13 at 20:10

Unless you are pre-transforming all of your vertex data, vertices should come into the vertex shader in object/model space. This is typically where the vertices are converted into screen space by transforming the vertex by the world, view, and projection matrices. If you want to perform operations on the vertices in world space, then either pass through the objects world transformation matrix in addition to a pre-multiplied world-view-projection matrix. Or pass in the world, view, and projection matrices separate from each other. You would then transform the vertex by the world matrix, perform all necessary operations on it, and then transform it by the view, and projection matrices before passing it through to the pixel shader.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.