CG Lecture 20, Thu 2016-10-20

  1. Estimated grades to date will be uploaded to LMS. It was computed as follows:

    1. The homeworks were scaled to have the same weight, added, and made a total weight of 48%.
    2. The midterm exam was weighted at 48%.
    3. Each iclicker class was given 1 if at least one question was answered. All the iclickers together were weighted at 4%.
    4. The class average was 76%. That would earn a B+.
  2. Handwritten notes from Wed.

  3. I added notes to yesterday's posting giving the big ideas from the slide sets.

  4. Iclicker questions.

  5. New slides:

    1. 7_4 Shadows.

      Big idea:

      1. If there is one light source, we can compute visibility with it as the viewer.
      2. Somehow mark the visible (i.e., lit) and hidden (i.e., shadowed) portions of the objects.
      3. Then recompute visibility from the real viewer and shade the visible objects depending on whether they are lit or shadowed.
      4. This works for a small number of lights.
  6. 7_5 Lighting and shading I.

    Big big topic.

  7. This Woman sees 100 times more colors than the average person.

  8. Phong lighting model: The total light at a pixel is the sum of

    1. Incoming ambient light times ambient reflectivity of the material at the pixel,
    2. Incoming diffuse light times diffuse reflectivity times a factor for the light source being low on the horizon,
    3. Incoming specular light times specular reflectivity times a factor for the eye not being aligned to the reflection vector, with an exponent for the material shininess,
    4. Light emitted by the material.
  9. That is not intended to be completely physical, but to give the programmer lots of parameters to tweak.

  10. In OpenGL you can do several possible levels of shading. Pick one of the following choices. Going down the list makes the shading better but costlier.

    1. Shade the whole polygon to be the color that you specified for one of the vertices.
    2. Bilinearly shade the polygon, triangle by triangle, from the colors you specified for its vertices.
    3. Use the Phong lighting model to compute the color of each vertex from that vertex's normal. Bilinearly interpolate that color over the polygon. That is called Gouraud shading.
    4. Bilinearly interpolate a surface normal at each pixel from normals that you specified at each vertex. Then normalize the length of each interpolated normal vector. Evaluate the Phong lighting model at each pixel from the interpolated normal. That is called Phong shading.
    5. Maureen Stone: Representing Colors as 3 Numbers (enrichment)
    6. Why do primary schools teach that the primary colors are Red Blue Yellow?
  11. Summary of the new part of shadedCube:

    1. var nBuffer = gl.createBuffer();

      Reserve a buffer id.

    2. gl.bindBuffer( gl.ARRAY_BUFFER, nBuffer );

      1. Create that buffer as a buffer of data items, one per vertex.
      2. Make it the current buffer for future buffer operations.
    3. gl.bufferData( gl.ARRAY_BUFFER, flatten(normalsArray), gl.STATIC_DRAW );

      Write a array of normals, flattened to remove metadata, into the current buffer.

    4. var vNormal = gl.getAttribLocation( program, "vNormal" );

      Get the address of the shader (GPU) variable named "vNormal".

    5. gl.vertexAttribPointer( vNormal, 3, gl.FLOAT, false, 0, 0 );

      Declare that the current buffer contains 3 floats per vertex.

    6. gl.enableVertexAttribArray( vNormal );

      Enable the array for use.

    7. (in the shader) attribute vec3 vNormal;

      Declare the variable in the vertex shader that will receive each row of the javascript array as each vertex is processed.

    8. The whole process is repeated with the vertex positions.

      Note that the variable with vertex positions is not hardwired here. You pass in whatever data you want, and your shader program uses it as you want.

  12. 8_1 Lighting and shading 2.