How to get the near plane position on object space coordinates?

Hello,

I have a scene with a cube and a full screen quad. Whenever the camera clips with the cube I need to transform the full screen quad vertices positions to the object space coordinates of the cube (and I need to do it in the full screen quad fragment shader). I already know when the camera clips with the cube but i’m not entirely sure on how to do the transformation, so any help is appreciated.

The vertices of a full-screen quad are (±1,±1,Z,1) in clip space, where Z is -1 at the near plane and +1 at the far plane. To get object-space coordinates, you need to transform those by the inverse of the model-view-projection matrix then divide by W.

You should be doing that in client code and storing the vertices as uniforms.