SHADING MODELS Nick Anastas
Feb 23, 2016
SHADING MODELSNick Anastas
OUTLINEo Virtual Objectso Phong Reflection Modelo Basic Shading Modelso Advanced Shading Models
OBJECTSo Made of planar
polygonso Any given planar
polygon can be broken down into triangles
o A triangles is fully defined by providing vertex coordinates and drawing order
NORMAL VECTOR (T & B, TOO)o The normal vector is
extremely importanto Unit Vectoro Can be formed knowing
vertex coordinates and drawing order
o Remember the Right Hand Rule!
o Tangent & Binormal, too
PHONG REFLECTION MODEL
PHONG REFLECTION MODELo Three types of light
o Diffuse: ID = KD * (N•L)o Specular: IS = KS *(R•V)n o Ambient: IA = KA
o So…o IP = KD * (N•L) + KS *(R•V)α + KA
BASIC SHADING MODELSo Three basic models
o Flat Shadingo Gouraud Shadingo Phong Shading
FLAT SHADINGo Only 1 normal vector
per triangleo Face normalo 1 Intensity value is
calculated at location of face normal
o This value is used at each pixel on the triangle
GOURAUD SHADINGo Calculate vertex normals
o At each vertex, vector add normals from every triangle that has that vertex as one of its own
o Unitize the vector sum to derive the vertex normal
o Calculate intensity at each vertexo Use the Phong reflection model
o Use bilinear interpolation to determine different intensity values at each pixel on the triangle
GOURAUD SHADINGo Looks much
better than flat shading
o Easy to calculateo Small specular
highlights are easily missed
PHONG SHADINGo Not to be confused with the Phong
reflection modelo Again, vertex normals must be
calculatedo New normal vectors are calculated at
each pixel by interpolating the vertex normals
o These new normals are used in the Phong reflection model to calculate different intensity values at each pixel
PHONG SHADINGo Interpolating the
vertex normals (not just intensities) across the triangle fixes Gouraud problem
o Still looks good
ADVANCED SHADING MODELS o Normal Map Shadero Environment Map Shader
NORMAL MAP SHADERo Make a nice model and a not-so-nice
oneo Very high polygon count on the nice model
o Record a ‘map’ of the normals of this high-poly model
o Replace the normals of the not-so-nice model with those recorded in the map
NORMAL MAPPINGo Get relatively
detailed-looking objects for little extra cost
o Object boundaries will reveal the use of a normal map
ENVIRONMENT MAP SHADERo Cube Environment
Mappingo Put object in a cube
whose inside walls are covered with the desired 2D images
o Use the intensity value of the location where the R (reflection) vector of a point intersects the box as that point’s intensity value
ENVIRONMENT MAP SHADERo Much cheaper than
ray tracingo Although the
reflection is not perfect, it is often ‘good enough’