shading models

18
SHADING MODELS Nick Anastas

Upload: shelby

Post on 23-Feb-2016

80 views

Category:

Documents


0 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Shading models

SHADING MODELSNick Anastas

Page 2: Shading models

OUTLINEo Virtual Objectso Phong Reflection Modelo Basic Shading Modelso Advanced Shading Models

Page 3: 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

Page 4: Shading models

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

Page 5: Shading models

PHONG REFLECTION MODEL

Page 6: Shading models

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

Page 7: Shading models

BASIC SHADING MODELSo Three basic models

o Flat Shadingo Gouraud Shadingo Phong Shading

Page 8: Shading models

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

Page 9: Shading models

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

Page 10: Shading models

GOURAUD SHADINGo Looks much

better than flat shading

o Easy to calculateo Small specular

highlights are easily missed

Page 11: Shading models

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

Page 12: Shading models

PHONG SHADINGo Interpolating the

vertex normals (not just intensities) across the triangle fixes Gouraud problem

o Still looks good

Page 13: Shading models

ADVANCED SHADING MODELS o Normal Map Shadero Environment Map Shader

Page 14: Shading models

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

Page 15: Shading models

NORMAL MAPPINGo Get relatively

detailed-looking objects for little extra cost

o Object boundaries will reveal the use of a normal map

Page 16: Shading models

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

Page 17: Shading models

ENVIRONMENT MAP SHADERo Much cheaper than

ray tracingo Although the

reflection is not perfect, it is often ‘good enough’