Lecture 10 - Blinn-Phong Local Model (cont.)
Recall from last time that we pick/compute colors per pixel, giving our 2D image (3D looking).
See Lecture 9 - Lighting!#^f758fb for the actual calculation.
Diffuse Light (Review)
Everything is at least slightly diffuse. Something being more rough implies that we have less diffuse light:
From last time:
Refer to Lecture 9 - Lighting!#^702881 for the final equation. The other things in those notes help supplement here.
Note that you will pick materials in your design yourself, which will affect the lighting. The obj
doesn't contain the material data, or anything relating to the lighting. It only has the normals (possibly unnormalized).
Some objs
actually do have material data in them. For our class, the tiny_obj
loader ignores these material coordinates, but you could modify it to help define these parameters.
Spectral Lighting
Instead of reflecting light in all directions, some surface are very smooth, almost like a mirror or piece of glass. On a surface like this, the light scatters perfectly w.r.t. the normal:
Here:
where
Notice for intuition that when
The idea between having to choose our
- For
this is how much color we just normally add when light hits the objects (note that the objects actual color can still be seen if we add no diffuse light). - For
, choose a color that we add of the "mirror-light" that we want to add. If there's a strobe effect that you want to be primarily white, make primarily white. Gold actually doesn't reflect perfectly yellow as a result of this (look it up).
Ambient Lighting
This is the color of the shadows on the surface.
The equation is:
Note how simple this is. We always would color black in total shadow, so if
Summary
In total, we have:
where:
We choose our
is the color we want to add when the light hits and object perfectly relative to the object. is the color we want to add when our view perfectly mirrors light from the surface. is the "default", black shadow light we'd want our object to have.
Sadly, considering where shadows are when rasterizing is very computationally intensive. One way we'll see how to deal with this later on is to project our other objects onto our ground/plane, then draw the surface with only the ambient "shadow" light. There also is a glm
planar projection shadow that helps project any object based on the surface/ground normals with respect to the light. The problem with this though is that not everything is a plane, so shadow-maps help solve this issue.
Getting :
We need to get the projection vectors to determine
So for our light vectors:
$$ \vec{R} = -L + 2(\vec{L} \cdot \vec{N})\vec{N} $$ But Blinn found that when the view angle is exactly the $\vec{R}$, we can get a new vector $\vec{H}$.Think about it this way. When
Another way to think of it is that the angle between
Doing this helps you remove some of the extra dot products that we would normally have to do.
Here:
Then our specular light becomes: