YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← Vertex and Fragment Shaders - Interactive 3D Graphics

Get Embed Code
2 Languages

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

  1. The vertex shader performs the transform of the vertex position to the screen.
  2. Its inputs are the vertex from the triangle along with whatever data the
  3. programmer wants to provide. For example, matrices and the colorful material
  4. could be passed in. The output of the vertex shader is a vertex with a
  5. transformed position. And possibly other information, such as the normal. The
  6. transform triangle is then rasterized. Triangle set up sends the data at each
  7. pixel inside a triangle to another programmable unit, the fragment shader. If
  8. you use Microsoft's DirectX API, this is called the pixel shader. Here's the
  9. layout for the fragment shader. This shader is handed various information from
  10. the triangle being processed. Somewhere to the vertex shader, the programmer
  11. can feed in any other data needed to process the triangles data at each pixel.
  12. The fragment shader's program is run, and the output not surprisingly, called a
  13. fragment Is typically a color and a z-depth, and possibly an alpha if you're
  14. using transparency. By the way, the reason we call it a fragment is that it
  15. represents the piece of the triangle covered by the pixel. At this point, this
  16. fragment color plus z-depth, is compared to the stored depth in the z-buffer.
  17. If the fragment is closer than the z-depth previously stored. The triangle is
  18. visible at this pixel and its color values are saved. The z-buffer test is
  19. again a fixed function bit of hardware. Notice how the fragment shader is
  20. pretty similar to the vertex shader in the way it functions. In fact, modern
  21. GPUs use what is called a unified shader in the hardware itself. These shader
  22. processors are assigned on the fly by the GPU, to execute vertex shader or
  23. fragment shader programs, depending on where the bottleneck is found.