0% found this document useful (0 votes)
45 views34 pages

Polygon Rendering: COMP 175: Computer Graphics November 17, 2011

This document discusses different polygon shading models used in 3D computer graphics. It begins by distinguishing between shading and lighting, with lighting evaluating illumination equations at points on a surface and shading interpolating values between vertices. Three common shading models are then described: flat/constant shading assigns a single value per polygon; Gouraud shading linearly interpolates values between vertices; and Phong shading interpolates surface normals to better handle specular highlights. The document concludes by discussing advanced shading techniques like shadows, environment mapping, and surface detail textures.

Uploaded by

Prem Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views34 pages

Polygon Rendering: COMP 175: Computer Graphics November 17, 2011

This document discusses different polygon shading models used in 3D computer graphics. It begins by distinguishing between shading and lighting, with lighting evaluating illumination equations at points on a surface and shading interpolating values between vertices. Three common shading models are then described: flat/constant shading assigns a single value per polygon; Gouraud shading linearly interpolates values between vertices; and Phong shading interpolates surface normals to better handle specular highlights. The document concludes by discussing advanced shading techniques like shadows, environment mapping, and surface detail textures.

Uploaded by

Prem Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

COMP 175 | COMPUTER GRAPHICS

Lecture 19:

Polygon Rendering
COMP 175: Computer Graphics November 17, 2011
Remco Chang 19 Shading 1/34

COMP 175 | COMPUTER GRAPHICS

Shading vs. Lighting

How is Shading different from Lighting? Lighting evaluates the lighting equation at each point on the surface of an object Shading is kind of a hack that computes only lighting equations on the vertices, and interpolates the pixels in between
19 Shading 2/34

Remco Chang

COMP 175 | COMPUTER GRAPHICS

Shading Models Flat/Constant

We define a normal at each polygon (not at each vertex) Lighting: Evaluate the lighting equation at the center of each polygon using the associated normal Shading: Each sample point on the polygon is given the interpolated lighting value at the vertices (i.e. a total hack)

Remco Chang

19 Shading

3/34

COMP 175 | COMPUTER GRAPHICS

Shading Models Gouraud


We define a normal vector at each vertex Lighting: Evaluate the lighting equation at each vertex using the associated normal vector Shading: Each sample points color on the polygon is interpolated from the color values at the polygons vertices which were found in the lighting step

Remco Chang

19 Shading

4/34

COMP 175 | COMPUTER GRAPHICS

Shading Models Phong

Each vertex has an associated normal vector Lighting: Evaluate the lighting equation at each vertex using the associated normal vector Shading: For every sample point on the polygon we interpolate the normals at vertices of the polygon and compute the color using the lighting equation with the interpolated normal at each interior pixel

Remco Chang

19 Shading

5/34

COMP 175 | COMPUTER GRAPHICS

Shading Models Compared


Constant shading: no interpolation, pick a single representative intensity and propagate it over entire object. Loses almost all depth cues.

Pixar Shutterbug images from:


www.siggraph.org/education/materials/HyperGraph /scanline/shade_models/shading.htm

Remco Chang

19 Shading

6/34

COMP 175 | COMPUTER GRAPHICS

Shading Models Compared


Flat or Faceted Shading: constant intensity over each face

Constant Shading
Remco Chang 19 Shading 7/34

COMP 175 | COMPUTER GRAPHICS

Shading Models Compared


Gouraud Shading: Linear Interpolation of intensity across triangles to eliminate edge discontinuity

Flat Shading
Remco Chang 19 Shading 8/34

COMP 175 | COMPUTER GRAPHICS

Shading Models Compared


Phong Shading: Interpolation of vertex surface normals
Note: specular highlights but no shadows. Still a pure local illumination model

Gouraud Shading
Remco Chang 19 Shading 9/34

COMP 175 | COMPUTER GRAPHICS

Shading Models Compared


Global Illumination: Objects enhanced using shadow, texture, bump, and reflection mapping (see S20)

Phong Shading
Remco Chang 19 Shading 10/34

COMP 175 | COMPUTER GRAPHICS

Shading Models Explained (1/6: Faceted)

Faceted Shading:

Single illumination value per polygon (GL_FLAT) With many polygons approximating a curved surface, this creates an undesirable faceted look. Facets exaggerated by Mach banding effect

Remco Chang

19 Shading

11/34

COMP 175 | COMPUTER GRAPHICS

Shading Models Explained (2/6: Gouraud)

Illumination intensity interpolation (GL_SMOOTH)


Illumination values are computed at vertices, linearly interpolated across the pixels of the polygon Eliminates intensity discontinuities at polygon edges; still have gradient discontinuities, Mach banding is largely ameliorated, not eliminated Must differentiate desired creases from tesselation artifacts (edges of cube vs. edges on tesselated sphere) Step 1: Compute vertex normals by averaging surrounding polygon normals

Remco Chang

19 Shading

12/34

COMP 175 | COMPUTER GRAPHICS

Shading Models Explained (3/6: Gouraud cont.)

y1
ys Ia

I1
Ib
Ip
scan line

y2 y3

I2

I3

y s y2 I2 y1 y2 y y3 I b I1 s I3 y1 y3 xb x p I p Ia Ib xb xa I a I1

y1 ys y1 y2 y1 ys y1 y3 x p xa
xb xa

Remco Chang

September 19 Shading 3, 2013

13

13/34

COMP 175 | COMPUTER GRAPHICS

Shading Models Explained (4/6: Gouraud cont.)

Remco Chang

19 Shading

14/34

COMP 175 | COMPUTER GRAPHICS

Shading Models Explained (5/6: Gouraud cont.)

Gouraud shading can miss specular highlights because it interpolates vertex colors instead of calculating intensity directly at each point, or interpolating vertex normals Na and Nb would cause no appreciable specular component, whereas Nc would. Interpolating between Ia and Ib misses the highlight that evaluating I at c would catch

Phong shading:

Interpolated normal comes close to the actual normal of the true curved surface at a given point Reduces temporal jumping affect of highlight, e.g., when rotating sphere during animation (example on next slide)
19 Shading 15/34

Remco Chang

COMP 175 | COMPUTER GRAPHICS

Shading Models Explained (6/6: Phong Shading)

Phong Model: normal vector interpolation Interpolate N rather than I Always captures specular highlights, but computationally expensive At each pixel, N is recomputed and normalized (requires sq. root operation) Then I is computed at each pixel (lighting model is more expensive than interpolation algorithms) This is now implemented in hardware, very fast Looks much better than Gouraud, but still no global effects

Gouraud
Remco Chang

Phong
19 Shading

Gouraud

Phong
16/34

http://en.wikipedia.org/wiki/Gourad_shading

COMP 175 | COMPUTER GRAPHICS

Gouraud vs. Phong Shading

Remco Chang

19 Shading

17/34

COMP 175 | COMPUTER GRAPHICS

Questions?

Remco Chang

19 Shading

18/34

COMP 175 | COMPUTER GRAPHICS

Advanced Techniques (Shadows 1/2)

Total hack: Project object on ground plane and render it as black polygon. Eye less sensitive to exact geometry than to contrast of shadow Projective shadows (shadow mapping)

Use orthographic or perspective matrix as CTM to project object (shadow caster) against another object; render the shadow object as another primitive Good for single light scenes with shadows cast on planes Extrude silhouette volume from object (shadow caster) to infinity in the direction opposite the light source Silhouette edge is made up of adjacent polygons, any point within the volume is in shadow

Shadow volumes

Implemented by former cs123 ta Kevin Egan and former PhD student and book co-auther Prof. Morgan McGuire, on nVidia chip

Remco Chang

19 Shading

19/34

COMP 175 | COMPUTER GRAPHICS

Advanced Techniques (Shadows 2/2)

Shadow Maps

Transform camera to each directional light source

Render the scene from the light source POV, keeping the same far clipping plane, update z-buffer only Read the z-buffer back and apply as a texture (shadow map) to the scene projected from the lights POV Render the scene from the eye point. At each pixel, if distance from light is greater than in the shadow map, the object is in shadow. Major aliasing problem, but implemented in hardware

Light

Shadow Map

By keeping the same far clipping plane, relative distances in Z are preserved

Remco Chang

September 19 Shading 3, 2013

20

20/34

COMP 175 | COMPUTER GRAPHICS

Advanced Techniques (Environment Mapping)

A way to render reflections (also called reflection mapping)


Simulates reflections with a texture map applied to the enclosing sphere or cube of an object Texture map can either be an existing image or a rendering of the scene from the objects perspective

Shiny metal effect using environment map.

Cube environment map is created by stitching together 6 textures, each generated by rendering the scene from the objects POV Ray from eye is reflected over surface normal and intersected with the environment map to get texture coordinates.
19 Shading 21/34

Remco Chang

COMP 175 | COMPUTER GRAPHICS

Advanced Techniques (Surface Detail)

Overview: There are several hacks to approximate the lighting and shading of complex geometry without actually describing the geometry only used for fine detail
Desired Geometry

Perturb geometric normals with bump map

Approximate geometry at render time with displacement map

Replace normals of simpler geometry with normal map

Remco Chang

19 Shading

22/34

COMP 175 | COMPUTER GRAPHICS

Surface Detail (Bump Mapping)

Texture mapping a rough surface onto an object doesnt achieve desired effect. Illumination is too uniform Blinns technique: Use an array of values (stored in a texture called the bump map) to perturb the surface normals by calculating gradient of bump map and adding it to the surface normal Evaluate lighting model with perturbed normals Effect is convincing, but objects still look smooth at silhouette edges

Spherical Surface
Remco Chang 19 Shading

nVidia

23/34

COMP 175 | COMPUTER GRAPHICS

Bump Mapping Example

The tin foil on this Hersheys Kiss looks too smooth

Remco Chang

19 Shading

24/34

COMP 175 | COMPUTER GRAPHICS

Bump Mapping Example

Bump Mapped: Tin foil look with no increase in model complexity.

Edges still dont look quite right


19 Shading 25/34

Remco Chang

COMP 175 | COMPUTER GRAPHICS

Normal Mapping

Similar to bump mapping, but better for highly detailed surfaces with drastically varying normals

Bump mapping uses a single channel height field to perturb normals, while normal mapping uses a three channel map to actually replace existing surface normal x, y, and z components of the desired normal, stored in the r, g, and b channels of an image

Level of detail is now limited by normal map resolution, not number of triangles

Runtime surface normal determination is as easy as a texture lookup

Limitations:

Same as bump map, silhouette edges lack the added detail Though easy to use at runtime, normal maps are difficult to generate
19 Shading 26/34

Remco Chang

COMP 175 | COMPUTER GRAPHICS

Normal Mapping Examples

Render showing actual, simple underlying geometry

Normal mapping can completely alter the perceived geometry of a model Image courtesy of www.anticz.com
19 Shading 27/34

When a normal map is applied, there appears to be much more detail in the model than actually is

Remco Chang

COMP 175 | COMPUTER GRAPHICS

Normal Map Creation (1/3)

While bump maps can be simply drawn, normal maps hold meaningful data in three overlapping channels
Normal map for a human face. Red, green, and blue channels correspond to x, y, and z normal components
www.bitmanagement.com

Normal map for brick street

www3.telus.net

Normal maps are not visually intuitive like height maps. How are they created?
19 Shading 28/34

Remco Chang

COMP 175 | COMPUTER GRAPHICS

Normal Map Creation (2/3)

Normal maps must be generated by specialized software, such as Pixologics Zbrush (www.pixologic.com)

A high resolution model is created by an artist and its normals are used to generate a normal map for a low resolution model.

3D geometry

Low-res mesh (~5,000 polygons)

Normal Map

High-resolution model (~2 million polygons)

Final render with normal map applied to low-res mesh (and lighting and texture maps). This is only 5,000 triangles!

Remco Chang

19 Shading

29/34

COMP 175 | COMPUTER GRAPHICS

Normal Mapping Creation (3/3)

See SIGGRAPH paper: A general method for preserving attribute values on simplified meshes by Cignoni, Montani, Rocchini, Scopigno

Remco Chang

19 Shading

30/34

COMP 175 | COMPUTER GRAPHICS

Other Surface Detail Techniques (1/3)

Displacement Map:

The actual geometric position of points over the surface are displaced along the surface normal according to the values in a texture

The displacement map used to render the scene. The intensity value indicates the height at a given point.

http://www.creativemac.com/2004/02_feb/tutorials/koc4ddisplace040224.htm

Remco Chang

19 Shading

31/34

COMP 175 | COMPUTER GRAPHICS

Other Surface Detail Techniques (2/3)

Parallax Mapping:

Displaces texture coordinates of a surface point by a function of the view angle relative to the surface normal and the value on the height map at that point

Steep Parallax Mapping:

Similar scheme to produce self-occlusion self-shadows of parallax mapped surface; More efficient and reduces swim effect for high frequency maps (Morgan McGuire Ph.D. 06 and Max McGuire)
Texture Mapped Texture and Parallax Mapped

Remco Chang

19 Shading

32/34

COMP 175 | COMPUTER GRAPHICS

Other Surface Detail Techniques (3/3)

Texture Mapped Normal Mapped: Increased depth in rock wall Parallax Mapped: Increased depth of whole texture but unwanted swim Steep Parallax Mapped: Very realistic depth in effect. Textures look like they whole picture. Lion head, columns cast self should be 3D but they stay shadows embedded in surface, unsettling to the eye when moving http://graphics.cs.brown.edu/games/SteepParallax/index.h tml

Remco Chang

19 Shading

33/34

COMP 175 | COMPUTER GRAPHICS

Questions?

Remco Chang

19 Shading

34/34

You might also like