MaT
MaT

Reputation: 1606

Project camera depth onto a 3D plane

Is it possible to project the camera depth onto a plane ?
Let me explain, if I simply transfer the depth buffer on a plane, it will always display the depth from the camera point of view. But how can I proceed to display the depth but from the plane point of view.
I want to apply the effect on a shader. For me it's maybe a matrix problematic but I don't get it.

Upvotes: 1

Views: 470

Answers (1)

Adrian Maire
Adrian Maire

Reputation: 14815

The depth buffer is relative to the representation, it is possible to project it to any plane using (for example) shaders. But..

The depth buffer is not a full geometrical representation of the object, but only of the "being seen" surface from the camara POV. If you project the depth buffer, part of the object will probably not be projected (see image).

In the picture, the camara (the red eye) is looking to an object (black). The depth buffer represent the distance between the camara and the red surface. For the plane (blue line) you probably want to get the entire object projection (blue surface), but projecting the red surface on the plane, you will only get a little portion of the entire blue surface.

Projection depth buffer

If you want the entire blue surface,

  1. Change the POV of the camara to just behind the plane.
  2. Render the scene.
  3. Get your depth buffer and save it into a texture/image/buffer (P).
  4. Reset your camara POV
  5. Render the scene with using for your shader the image (P)

Upvotes: 2

Related Questions