Review Detail: Adding a second light source exposed a problem with the demo Set up a white source on one side, look at it, add colored on the other Midterm Review! Midterm is on Monday! Let's put together a midterm review guide It'll be a fair bit different from last time I taught this course Lab assignments will be a part of it We'll see what's on it... Normals, and calculation in different spaces The model is not actually in model space if we've scaled, etc. The normal vectors are in model space So couldn't we just transform them with the model matrix, and put the camera in world space? Sure, why not? What if we flatten it? Can we force a visible problem? We'll try... I'm not sure this is going to be easy to see, though This is only a problem if the object has had a non-uniform scale applied Can avoid overhead if you just make the models so they don't need a non-uniform scale The fix: Compute the inverse-transpose matrix, and multiply by that instead If you're really interested in 3D, take linear algebra. It counts as an upper-division elective Maybe we'll do this later Do it once on the CPU instead of a whole bunch of times on the card A very practical note about normal vectors and vertices: With the cube, we're storing each vertex once Each vertex has THREE normal vectors! obj file internals Can manage this with a variety of buffers Don't sweat it too much. In a curved mesh, each vertex just has one normal Ambiant Light Doesn't exist (we'll use it anyway) Basically, we just add a little "bonus" light Can use diffuse colors Can set an ambiant color, for the extra light Diffuse gives us a term, R L = R + A Can't exceed 1.0 here - OpenGL will clamp the color at 1.0 This'll cause the color to be washed out if it exceeds 1.0 More terms will keep being added! Dynamic range Point lighting: A directional light for diffuse lighting comes from some direction A point light comes from a point We can figure out a direction to a point, not a problem? More or less defeats gouraud shading, depends on triangle size Fragment shader: Must preserve surface location and normal Attenuation: Decrease light power with distance! Real: I / (1.0 + k*r^2) k constant: Can use distance where half the light is lost Less attenuation: I / (1.0 + k*r) Just take out the r, and lights work when further away Calculations happen in world-space distances Can compute from camera space, or preserve, or whatnot We'll stick with world again Can we make a point that moves between two spheres? Specular Reflection: Reflection in a specific direction! Comes with a different color Microfacets, roughness Angle to the camera matters! Phong: dot product of V and R raised to the s power V is the viewing direction R is the reflection direction s is a term that represents roughness The Phong term is multiplied by the light intensity and the specular absorption Specular absorption might not be the same color as diffuse absorption Only works for angle less than 90 Blinn term: Use half angle vector Gaussian: Probability distribution of microfaucets Dynamic and HDR lights Practice: Add some kind of model into a lighting demo