https://paroj.github.io/gltut/Illumination/Tutorial%2009.html This is pretty old, but still relevant Special for today: http://www.lighthouse3d.com/tutorials/glsl-12-tutorial/the-normal-matrix/ Notes about progress of the course: I'm heading toward ray tracing Already finished the intro class and example, actually Adding some stuff to the nVidia tutorials Still thinking about the best amount of abstraction Concerned nVidia is too much still Haven't got it to build on FreeBSD yet Maybe it's actually easy on Windows? Would somebody mind checking? I can, but it'll take me forever Normals, and calculation in differenct spaces The model is not actually in model space if we've scaled, etc. The normal vectors are in model space MVP and what happens to these Short answer: Compute the inverse-transpose matrix, and multiply by that instead Make sure it's 3x3 to kill translation. Could also just set w to 0. If you're really interested in 3D, take linear algebra. It counts as an upper-division elective Do it once on the CPU instead of a whole bunch of times on the card 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 Alright: Goal I haven't gotten to for a long time I'd like a point source lab Let's improve the load_object a little for this I already did, at least party To save you watching too much of me typing 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? 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 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