← Clipping - Interactive 3D Graphics

• 2 Followers
• 34 Lines

Get Embed Code x Embed video Use the following code to embed this video. See our usage guide for more details on embedding. Paste this in your document somewhere (closest to the closing body tag is preferable): ```<script type="text/javascript" src='https://amara.org/embedder-iframe'></script> ``` Paste this inside your HTML body, where you want to include the widget: ```<div class="amara-embed" data-url="http://www.youtube.com/watch?v=-jhYLJHp2_c" data-team="udacity"></div> ``` 2 Languages

Showing Revision 5 created 05/24/2016 by Udacity Robot.

1. I left out a step that happens after projection and before division by W.
2. Clipping. Say we have 2 points: 0, 4, negative 6 after perspective
3. transformation that turns into 0, 4, 5, 6 and 0, 6, negative 4, which turns
4. into this value. They form a line segment. These two points in this line
5. segment are shown on this zoomed in part of our frustum. The second point is
6. outside of the frustum. We want to have all coordinates inside our final view
7. volume in NDC space so that we can render them. Clipping is done for line
8. segments and triangle edges that poke out through the frustum. An edge can be
9. clipped by any numbers of faces of the frustum. What happens here is that all
10. the coordinates between the two points get linearly interpolated. For our
11. example the point on the frustum faces halfway between our two points. The
12. interpolated point is then 0, 5, 3.85. We then divide this point by W as usual
13. to get a point in normalized device coordinates. Here's a rough overview of how
14. clipping can work. You start with a triangle that's poking out through the
15. frustum. Say the left face of the frustum first cuts the triangle. This creates
16. two triangles. Later, the top face of the frustum chops off the other part of
17. the triangle. This create three triangles total that will then be rasterized
18. separately by the GPU. You as a user don't really have to know or care much
20. mostly if you need to do similar testing operations on the CPU side. In
21. computer graphics we often make a big deal about how we store 3D points in
22. vectors as homogeneous coordinates, with the fourth element W. In reality, for
23. almost every operation, the W value is either 0, meaning a vector, or 1,
24. meaning a point. It's only after projection and during clipping that the W
25. value is anything but 1. Once clipping is done and we're using normalized
26. device coordinates, we're done with homogeneous coordinates. However, these
27. homogeneous coordinates are important in that they're what the vertex shader
28. produces. When the coordinate is transformed by the projection matrix, but
29. before the division is performed, the coordinates are called clip coordinates.
30. The vertex shader can produce other intermediate results, such as computing
31. location once the model and view matrices are applied. It is required that the
32. vertex shader produce a position on the screen for the vertex. This position is
33. a homogeneous coordinate. The rasterizer then takes this position and performs
34. clipping.