To improve my understanding of OpenGL and 3D, I am trying to implement a simple rendering pipeline that only runs on the processor. Where this makes sense, I try to use the same standards as OpenGL. For example, I use the right coordinate system as OpenGL . As is often the case when learning something new, I now have a question that I can’t find an answer to. If something in the following does not make sense, please forgive and correct me.
In the clip space (the coordinate that you pass gl_Position
in your vertex shader), negative Z is away from the user. But in the depth buffer, a positive Z is far away (if you use the default depth settings).
One answer to this question suggests that switching is due to projection transformation. But I did a little experiment (based on WebGL / OpenGL ES) that suggests the opposite: in the clip space, Z indicates from the user even if you are not using projection transform.
So, at some point, after you passed it to gl_Position
, OpenGL will flip the Z coordinate. When and how is it?
My hunch is that it is in species conversion , but I could not find the documentation that supports this.
source share