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

Programmable Pipeline and GLSL


  1. OpenGL Programmable Pipeline
  2. Vertex Shading Stage
  3. Vertex Shader Example
  4. Uniforms
  5. Fragment Shading Stage
  6. GLSL, OpenGL Shading Language
  7. GLSL variable types - scalar
  8. GLSL variable types - vector
  9. GLSL operators
  10. Common vector operators
  11. GLSL elements of vectors and matrices
  12. GLSL Efficiency
  13. matrix component selection
  14. GLSL variable types - matrices
  15. GLSL matrix types, cont.
  16. GLSL Storage Qualifiers
  17. noperspective example
  18. GLSL built-in functions
  19. GLSL Geometric functions
  20. GLSL common functions
  21. GLSL floating point support
  22. GLSL variable types - containers

1. OpenGL Programmable Pipeline



2. Vertex Shading Stage



3. Vertex Shader Example


  • Examples of in global variables

    • Raw vertex positions

    • Normals

    • Texture coordinates

    • Vertex colors

    • Any other things -- you decide

  • 
    #version 130
    
    // vertices in NDC coordinate system:
    in vec4 vPosition;
    
    void main () {
        gl_Position = s_vPosition;
    }
    
    

4. Uniforms


  • Uniforms are the same for all vertces

  • Queried by glGetUniformLocation()

  • Set by glUniform*()

  • Apply to both vertices and fragments

  • Denoted by the uniform type modifier

  • The value of uniform is constant in the shader code

  • Uniforms are usefull to pass:

    • Matrices, e. g. Model-View-Perspective

    • Light positions

  • 
    #version 130
    
    in vec4 vPosition;
    in vec4 vNormal;
    
    uniform mat4 mM;
    uniform mat4 mV;
    uniform mat4 mP;
    uniform mat4 mRotations;
    
    uniform vec4 vLight;
    
    void main () {
        
        /*rotate normals...*/
        /*if rotating camera, rotate light
          direction as well...*/
        
        // Go model to world, then to camera,
        //then to NDC coordinates:
        gl_Position = mP * mV * mM * vPosition;
    }
    
    

5. Fragment Shading Stage



6. GLSL, OpenGL Shading Language



7. GLSL variable types - scalar



8. GLSL variable types - vector



9. GLSL operators



10. Common vector operators



11. GLSL elements of vectors and matrices



12. GLSL Efficiency



13. matrix component selection



14. GLSL variable types - matrices



15. GLSL matrix types, cont.



16. GLSL Storage Qualifiers



17. noperspective example


  • Perspective interpolation

      TODO

  • No perspective interpolation

      TODO


18. GLSL built-in functions



19. GLSL Geometric functions



20. GLSL common functions



21. GLSL floating point support



22. GLSL variable types - containers