Lecture 10 - Blinn-Phong Local Model (cont.)

Recall from last time that we pick/compute colors per pixel, giving our 2D image (3D looking).

Color=Rdiffuse+Rspecular+Rambient

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).

Umm... actually

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:

Lspecular=Ks(VR)α

where KS is some specular color, and α is the "shinniness coefficient". Again, here KS is another RGB value. The R is the perfect reflection vector, where we perfectly rotate it θ (or in the image a) radians around N.

Notice for intuition that when V points in the direction of R, we get the maximum specular light. This is like when a mirror perfectly points the reflection of light right into your eye.

Choosing KS or Kd

The idea between having to choose our K values is:

  • For Kd 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 KS, 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 KS 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:

Lambient=Ka

Note how simple this is. We always would color black in total shadow, so if Ka is still total black, we still keep the black color. You can think of Ka as the "null" color of the object, where in total darkness we have this color.

Summary

In total, we have:

Ltotal=Ldiff+Lspecular+Lambient

where:

Ldiff=KdNL|N||L|Lspecular=Ks(VR)αLambient=Ka

We choose our K's as:

Where's the shadow?

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 R:

We need to get the projection vectors to determine R recall that for vectors u,v that:

projw(u)=uw|w|w

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 V and R have a maximal dot product (they point in the same direction), then we have the maximal amount of specular light. If you add V+L then you get the vertical H vector, which points in the N direction.

Another way to think of it is that the angle between R and V is the same as the angle between N and H. As such, when V goes away from the R vector, then H moves away from N and reduces the magnitude of their dot products.

Doing this helps you remove some of the extra dot products that we would normally have to do.

Here:

H=V+L||V+L||

Then our specular light becomes:

Lspecular=KS(NH)a