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

Lab 7 -- Diffuse and specular light


  1. Part 1: Experimenting with lights
  2. Setting things up
  3. Part 1 project updates
  4. Things to do
  5. Part 2: Adding configuration window
  6. Visual Studio project updates
  7. Using the config window
  8. How to submit

1. Part 1: Experimenting with lights



2. Setting things up



3. Part 1 project updates


  1. The vertex shader now includes lightPosition input variable.

  2. The Light C++ class is added to the source code:

    
        Shader* myShader = new Shader( BCC_VERTEX_SHADER, BCC_FRAGMENT_SHADER );
        //...
        light = new Light( light_pos, light_ambient, light_diffuse, light_specular, myShader );
        myModel = new Model( myShader );
        //...
        myModel->set_material( material_ambient, material_diffuse, material_specular, shininess );
        myModel->set_light( light );
    
    

    Here, most of the parameters are arrays of 4 GLfloats.

  3. The shininess is in range 1 to 255.

  4. The render() function also calls

    
        light->set_shader_light_position();
    
    

    because the light position can move around.

  5. The Model::render() function combines all light components and uploads them to OpenGL.

  6. In the vertex shader the are three new out variables:

  7. In the fragment shader,

     


4. Things to do



5. Part 2: Adding configuration window



6. Visual Studio project updates



7. Using the config window



8. How to submit