English subtitles

← Clipping - Interactive 3D Graphics

Get Embed Code
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
  19. about this clipping process. It happens automatically. It's worth knowing about
  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.