180 likes | 413 Views
Nick Anastas. Shading models. Virtual Objects Phong Reflection Model Basic Shading Models Advanced Shading Models. Outline. Made of planar polygons Any given planar polygon can be broken down into triangles A triangles is fully defined by providing vertex coordinates and drawing order.
E N D
Nick Anastas Shading models
Virtual Objects • Phong Reflection Model • Basic Shading Models • Advanced Shading Models Outline
Made of planar polygons • Any given planar polygon can be broken down into triangles • A triangles is fully defined by providing vertex coordinates and drawing order Objects
The normal vector is extremely important • Unit Vector • Can be formed knowing vertex coordinates and drawing order • Remember the Right Hand Rule! • Tangent & Binormal, too Normal Vector (T & B, too)
Three types of light • Diffuse: ID = KD * (N•L) • Specular: IS = KS *(R•V)n • Ambient: IA = KA • So… • IP = KD * (N•L) + KS *(R•V)α + KA Phong Reflection Model
Three basic models • Flat Shading • Gouraud Shading • Phong Shading Basic Shading Models
Only 1 normal vector per triangle • Face normal • 1 Intensity value is calculated at location of face normal • This value is used at each pixel on the triangle Flat Shading
Calculate vertex normals • At each vertex, vector add normals from every triangle that has that vertex as one of its own • Unitize the vector sum to derive the vertex normal • Calculate intensity at each vertex • Use the Phong reflection model • Use bilinear interpolation to determine different intensity values at each pixel on the triangle Gouraud Shading
Looks much better than flat shading • Easy to calculate • Small specular highlights are easily missed Gouraud Shading
Not to be confused with the Phong reflection model • Again, vertex normals must be calculated • New normal vectors are calculated at each pixel by interpolating the vertex normals • These new normals are used in the Phong reflection model to calculate different intensity values at each pixel Phong Shading
Interpolating the vertex normals (not just intensities) across the triangle fixes Gouraud problem • Still looks good Phong Shading
Normal Map Shader • Environment Map Shader Advanced Shading Models
Make a nice model and a not-so-nice one • Very high polygon count on the nice model • Record a ‘map’ of the normals of this high-poly model • Replace the normals of the not-so-nice model with those recorded in the map Normal Map Shader
Get relatively detailed-looking objects for little extra cost • Object boundaries will reveal the use of a normal map Normal Mapping
Cube Environment Mapping • Put object in a cube whose inside walls are covered with the desired 2D images • 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 shader
Much cheaper than ray tracing • Although the reflection is not perfect, it is often ‘good enough’ Environment map shader
Thank You Questions?