Course list http://www.c-jump.com/bcc/

OpenGL Shaders Intro


  1. Triangulation
  2. Triangulation, cont.
  3. Programmable graphics pipeline
  4. Shader is a program
  5. Vertex and Fragment processing
  6. Compiling a shader program
  7. Using separate shaders
  8. Vertex and Fragment shader example
  9. GLSL #version number
  10. Compiling a shader program example
  11. Shaders embedded in C++

1. Triangulation


  • A vertex is a 3D point (x, y, z)

  • A triangle

    • is made from 3 vertices

    • has a normal

      triangle normal

                     
  • Each vertice can have a normal specified:

      triangle normal


2. Triangulation, cont.



3. Programmable graphics pipeline


  • Hardware provides access to its graphics pipeline

  • The graphics pipeline is programmable

  • OpenGL uses "shader programs" or, simply, shaders to manipulate the hardware graphics pipeline

  • OpenGL 3.3 Pipeline (Lighthouse3d.com):

      OpenGL 3.3 Pipeline


4. Shader is a program



5. Vertex and Fragment processing



6. Compiling a shader program


  1. Compile a vertex shader -> returns shader ID

  2. Compile a fragment shader -> returns shader ID

  3. Check for compilation errors

  4. Create a shader program -> returns program ID

  5. Attach to a vertex and fragemnt shaders to the program

  6. Link those two shaders together

  7. Use program ID before you render triangles

     


7. Using separate shaders



8. Vertex and Fragment shader example



9. GLSL #version number



10. Compiling a shader program example



11. Shaders embedded in C++