<p>The perspective projection matrix transforms from camera space to clip space. The near-plane value is the position of the near plane in camera space. So in case that your world space to camera space transformation does not use any scaling, only rotations and translations, then if you place the camera <span class="math-container">$z$</span> units away from the billboard surface and look directly onto it, a near plane value of <span class="math-container">$z$</span> will cause the billboard plane to lie on the near plane. Due to rounding errors, it might get clipped away, so your idea of setting it to <span class="math-container">$z-offset$</span> should solve the problem.</p>
<p>Why it doesn't work is hard to tell without any code. Maybe your implementation of the perspective matrix is wrong. Maybe you have a hidden scaling when you transform between world and camera space. To debug this you can try to multiply <span class="math-container">$z$</span> with values between 0 and 1 until you get the desired result. The resulting factor might be a clue. For example if you get <span class="math-container">$0.5$</span> we know that there is either a 2 missing or too much in your transformation matrices. Also, make sure that your far plane value is larger than your near plane value (even though I think from your description that this isn't the problem - but who knows)</p>
<p>In case you are using OpenGL, here is a <a href="http://www.songho.ca/opengl/gl_projectionmatrix.html" rel="nofollow noreferrer">link to how the perspective projection matrix has to look like</a>. Maybe you have to transpose the matrix. That depends on your vector layout - column vectors or row vectors.</p>
<p><a href="https://computergraphics.stackexchange.com/a/9960/13095">Here is a link to an answer of mine</a> to another question. It has a Python script at the end that you can use to visualize how the different values affect the view frustum in the different spaces. Some pictures are also included in the answer. Maybe that is already enough to help you out.</p>

CC BY-SA 4.0
2020-08-20T07:35:18.573Z
2020-08-20T07:35:18.573Z
wychmaster
<p>I have a camera I have placed <code>z</code>units away from a billboarded rect. My goal is to discard all other geometry that is closer to the camera/in front of this rect.</p>
<p>With perspective projection I have always set the near plane to 0.1 and called it a day however here I tried to set it to <code>z</code> thinking it would clip anything in front of this rect.</p>
<p>No such luck. This ended up clipping that rect and seemingly even more. Z-1 also did not have the desired result.</p>
<p>This leads me to think the near clipping plane might not be in the same coordinate space as the world? If not what space is it in?</p>

<matrix><perspective>
Perspective projection near plane not in world coordinates
J.Doe
# Perspective projection near plane not in world coordinates

(Asked by: username_0 on 2020-08-19)

I have a camera I have placed `z`units away from a billboarded rect. My goal is to discard all other geometry that is closer to the camera/in front of this rect.

With perspective projection I have always set the near plane to 0.1 and called it a day however here I tried to set it to `z` thinking it would clip anything in front of this rect.

No such luck. This ended up clipping that rect and seemingly even more. Z-1 also did not have the desired result.

This leads me to think the near clipping plane might not be in the same coordinate space as the world? If not what space is it in?

**Tags:** matrix, perspective


---

## 1 answers

### Answer by username_1 on 2020-08-20. Score: 1 | Accepted answer

The perspective projection matrix transforms from camera space to clip space. The near-plane value is the position of the near plane in camera space. So in case that your world space to camera space transformation does not use any scaling, only rotations and translations, then if you place the camera $z$ units away from the billboard surface and look directly onto it, a near plane value of $z$ will cause the billboard plane to lie on the near plane. Due to rounding errors, it might get clipped away, so your idea of setting it to $z-offset$ should solve the problem.

Why it doesn't work is hard to tell without any code. Maybe your implementation of the perspective matrix is wrong. Maybe you have a hidden scaling when you transform between world and camera space. To debug this you can try to multiply $z$ with values between 0 and 1 until you get the desired result. The resulting factor might be a clue. For example if you get $0.5$ we know that there is either a 2 missing or too much in your transformation matrices. Also, make sure that your far plane value is larger than your near plane value (even though I think from your description that this isn't the problem - but who knows)

In case you are using OpenGL, here is a [link to how the perspective projection matrix has to look like](http://www.songho.ca/opengl/gl_projectionmatrix.html). Maybe you have to transpose the matrix. That depends on your vector layout - column vectors or row vectors.

[Here is a link to an answer of mine](https://computergraphics.stackexchange.com/a/9960/13095) to another question. It has a Python script at the end that you can use to visualize how the different values affect the view frustum in the different spaces. Some pictures are also included in the answer. Maybe that is already enough to help you out.


---

