1) Context I'm using a regular OpenGL perspective projection matrix created with GLM (glm::perspective) and taking the inverse (glm::inverse) to transform clip-space back into view space (and world space ultimately). Now with z-values at the near and far plane it's easy to choose the x,y,z,w components of the clip-space cube corners and get the world space point of the frustum volume.

2) Question Now, I want to harness the fact that clip space is a cube and generate a grid over the frustum. for x,y this works with the regular inverse projection matrix. For z, if I take uniform subdivisions of the range [-1.0, 1.0] with w=1.0, the view space z values will not be linear. I haven't got enough sleep recently to convince myself to do the math. What would be an inverse projection matrix to do this?

  • \$\begingroup\$ "I want to harness the fact that clip space is a cube" Clip-space is not a cube. It's not even three dimensional; it's a four-dimensional homogeneous coordinate system. And what kind of grid are you trying to overlay? A grid is 2-dimensional, so what do you need the Z coordinate for? \$\endgroup\$ – Nicol Bolas Apr 24 '13 at 4:39
  • \$\begingroup\$ Q = Proj*P, Q = Q/Q.w the frustum will be a cube. So in that space it'll be easy to do any subdivision and map it back to the frustum. in world space... \$\endgroup\$ – FHoenig Apr 24 '13 at 5:32
  • \$\begingroup\$ technically, I'm actually talking about NDC space. \$\endgroup\$ – FHoenig Apr 24 '13 at 5:59

Browse other questions tagged or ask your own question.