<blockquote>
  <p>When do they actually discard points that have a z component smaller than the near clipping plane?</p>
</blockquote>

<p>For actual rendering hardware, they don't. Clipping happens in clip space, before the NDC transform. "Points" outside of the clipping volume are never seen by the rasterizer (in theory, at least. In practice, guard-band clipping is often used to minimize the need for clipping against the sizes).</p>

<p>The renderer presented at that site doesn't appear to do clipping at all. It has an approximation of what <em>would</em> be clipped, but it doesn't actually do the clipping. </p>

CC BY-SA 4.0
2020-01-02T16:29:49.687Z
2020-01-02T16:29:49.687Z
Nicol Bolas
<p>I don't understand something about the near clipping plane. It's there to avoid the division by <span class="math-container">$0$</span> but when we compute the pixel coordinates, we just need to multiply by the clipping plane to clip the object?</p>

<p>For example in this code, from <a href="https://www.scratchapixel.com/lessons/3d-basic-rendering/3d-viewing-pinhole-camera/implementing-virtual-pinhole-camera" rel="nofollow noreferrer">https://www.scratchapixel.com/lessons/3d-basic-rendering/3d-viewing-pinhole-camera/implementing-virtual-pinhole-camera</a></p>

<pre class="lang-cpp prettyprint-override"><code>pScreen.x = pCamera.x / -pCamera.z * near; 
pScreen.y = pCamera.y / -pCamera.z * near; 

Vec2f pNDC; 
pNDC.x = (pScreen.x + r) / (2 * r); 
pNDC.y = (pScreen.y + t) / (2 * t); 
pRaster.x = (int)(pNDC.x * imageWidth); 
pRaster.y = (int)((1 - pNDC.y) * imageHeight); 

bool visible = true; 
if (pScreen.x &lt; l || pScreen.x &gt; r || pScreen.y &lt; b || pScreen.y &gt; t) 
    visible = false; 

return visible; 
</code></pre>

<p>When do they actually discard points that have a z component smaller than the near clipping plane? They just discard those which have a x and y coordinate not visible to the screen.</p>

CC BY-SA 4.0
2020-01-02T11:41:08.360Z
Admittedly the meanings of the variable names aren't entirely clear to me, (eg does camera refer to the camera *or* a vertex transformed into camera space...I'll assume the latter) but that does *not* look like the correct thing to do.  You _can't_ do the division by Z before doing clipping. You must clip each line/primitive first before the division.
Simon F
<3d><projections><rasterizer>
Understanding the near clipping plane
Voko
# Understanding the near clipping plane

(Asked by: username_0 on 2020-01-02)

I don't understand something about the near clipping plane. It's there to avoid the division by $0$ but when we compute the pixel coordinates, we just need to multiply by the clipping plane to clip the object?

For example in this code, from <https://www.scratchapixel.com/lessons/3d-basic-rendering/3d-viewing-pinhole-camera/implementing-virtual-pinhole-camera>

```cpp
pScreen.x = pCamera.x / -pCamera.z * near; 
pScreen.y = pCamera.y / -pCamera.z * near; 

Vec2f pNDC; 
pNDC.x = (pScreen.x + r) / (2 * r); 
pNDC.y = (pScreen.y + t) / (2 * t); 
pRaster.x = (int)(pNDC.x * imageWidth); 
pRaster.y = (int)((1 - pNDC.y) * imageHeight); 

bool visible = true; 
if (pScreen.x < l || pScreen.x > r || pScreen.y < b || pScreen.y > t) 
    visible = false; 

return visible; 

```

When do they actually discard points that have a z component smaller than the near clipping plane? They just discard those which have a x and y coordinate not visible to the screen.

**Tags:** 3d, projections, rasterizer

> **Comments:**
> **username_1**: Admittedly the meanings of the variable names aren't entirely clear to me, (eg does camera refer to the camera *or* a vertex transformed into camera space...I'll assume the latter) but that does *not* look like the correct thing to do.  You _can't_ do the division by Z before doing clipping. You must clip each line/primitive first before the division.  

---

## 1 answers

### Answer by username_2 on 2020-01-02. Score: 0 | Accepted answer

> When do they actually discard points that have a z component smaller than the near clipping plane?

For actual rendering hardware, they don't. Clipping happens in clip space, before the NDC transform. "Points" outside of the clipping volume are never seen by the rasterizer (in theory, at least. In practice, guard-band clipping is often used to minimize the need for clipping against the sizes).

The renderer presented at that site doesn't appear to do clipping at all. It has an approximation of what *would* be clipped, but it doesn't actually do the clipping.


---

