Shading - PowerPoint PPT Presentation

1 / 40
About This Presentation
Title:

Shading

Description:

Shading Contents Definition Light sources Phong reflection model Polygonal shading Shading in OpenGL Global rendering ... – PowerPoint PPT presentation

Number of Views:93
Avg rating:3.0/5.0
Slides: 41
Provided by: 6649786
Category:
Tags: light | shading | shadow

less

Transcript and Presenter's Notes

Title: Shading


1
Shading
  • ????? ??? ???? ???

2
Contents
  • Definition
  • Light sources
  • Phong reflection model
  • Polygonal shading
  • Shading in OpenGL
  • Global rendering

3
Shading
  • Determine a color for each filled pixel
  • How to choose a color
  • the color of the light source and of the surfaces
    determines the color of one or more pixels in the
    frame buffer

4
Light and Matter
  • Color is determined by multiple interactions
    among light sources and reflective surfaces
  • recursive reflection of light between surfaces
    accounts for subtle shading

Rendering Equation
5
Light-Material Interactions
  • Specular surfaces mirror
  • scatter reflected light in a narrow range of
    angle
  • Diffuse surfaces chalk, clay
  • scatter reflected light all directions
  • Translucent surfaces glass, water
  • refraction

specular surface
diffuse surface
translucent surface
6
Light Sources
  • Illumination function I (x, y, z, ?, f, ?)
  • each point (x, y, z) on the surface
  • direction of emission (?, f)
  • wavelength ?

light source
7
Modeling Light Sources
  • Simple mathematical models
  • ambient light
  • point light
  • directional light
  • spot light

8
Color Sources
  • Three-color theory
  • human perceive three primary colors red, green,
    and blue
  • three-component intensity or luminance function
  • independent calculations

9
Ambient Light
  • Uniform lighting
  • identical at every point in the scene

10
Point Sources (1/2)
  • Emit light equally in all directions
  • p0 point source location
  • proportional to the inverse square distance

point source illuminating a surface
11
Point Sources (2/2)
  • Large finite size of most light sources
  • umbra full shadow
  • penumbra partial shadow
  • Attenuation

shadows created by finite-size light source
12
Spotlights
  • Characterized by a narrow range of angle through
    which light is emitted
  • ps apex of a cone
  • ls direction of pointing
  • ? angle to determine width
  • Distribution of light
  • concentrate in the center
  • light intensity drop off

spotlight
attenuation
exponent
13
Distant Light Sources
  • far from the surface ? vector does not change
  • location ? direction

parallel light source
14
Phong Reflection Model
  • Efficient and close enough approximation to
    physical reality to produce good renderings
  • Use 4 vectors
  • n normal at p
  • v direction from p to the viewer or COP
  • l direction from light source
  • r direction of reflectance
  • 3 types of material-light
  • interactions
  • ambient, diffuse, and specular

vectors used by the Phong model
15
Computation
  • Light source and reflection term
  • Ex. red intensity
  • Total Intensity

16
Ambient Reflection
  • Same at every point on the surface
  • Ambient reflection coefficient
  • amount reflected
  • some of light source is absorbed and some is
    reflected
  • three ambient coefficients , , and
  • Ambient reflection term
  • can be any of the individual light sources
  • can be a global ambient term

17
Diffuse Reflection (1/2)
  • Characterized by rough surfaces
  • perfectly diffuse surface
  • ? so rough that there is no preferred
  • angle of reflection
  • Lamberts law
  • only the vertical component of light source

rough surface
at noon
in the afternoon
Lamberts law
18
Diffuse Reflection (2/2)
  • Lamberts law (cont)
  • Diffuse reflection term
  • incorporate a distance term

Lamberts law
19
Specular Reflection
  • Specular surface is smooth
  • highlight in the direction of the viewer
  • Specular reflection term
  • shininess coefficient
  • a ? infinite mirror
  • 100 lt a lt 500 metal
  • a lt 100 broad highlight

specular highlights
specular surface
effect of shininess coefficient
20
Phong Model
  • Including the distance term

21
Utha Teapots with Different Material Properties
22
Computation of Vectors (1/2)
  • Normal vectors
  • in OpenGL
  • Angle of reflection

n
glNormal3f(nx, ny, nz) glNormal3fv(pointer_to_nor
mal)
coplanar condition
?
?
by ? and ?
mirror
23
Computation of Vectors (2/2)
  • Halfway vector
  • half-angle 2?f
  • Transmitted light
  • Snells law

halfway vector
perfect light transmission
24
Polygonal Shading
  • Shade a polygonal mesh
  • flat shading
  • interpolative or Gouraud shading
  • Phong shading

polygonal mesh
25
Flat Shading (1/2)
  • Constant shading
  • flat polygon
  • ? n constant
  • distant light source
  • ? l constant
  • distant viewer
  • ? v constant
  • One shading calculation for each polygon
  • In OpenGL

distant source and viewer
glShadeModel(GL_FLAT)
26
Flat Shading (2/2)
  • Always be disappointing for a smooth surface
  • lateral inhibition
  • human visual system has a remarkable sensitivity
  • Mach bands
  • perceive the increases in brightness along the
    edges

flat shading of polygonal mesh
perceived and actual intensities at an edge
We need smoother shading techniques to avoid it!!
27
Interpolative and Gouraud Shading
  • In OpenGL
  • One lighting calculation for each vertex
  • bilinearly interpolate colors
  • Vertex normal could be defined through
    interpolation

glShadeModel(GL_SMOOTH)
normals near interior vertex
28
Wireframe
29
Flat Shading
30
Gouraud Shading
31
Phong Shading
  • May not prevent the appearance of Mach bands
  • What if polygonal mesh is too coarse to capture
    illumination effects in polygon interiors?
  • One shading calculation for each pixel ? off-line
  • Compute vertex normal at each point

interpolate normals across each polygon
interpolation of normals
edge normals
32
Visible-Line Determination
33
Visible-Surface Determination with Ambient
Illumination Only
34
Flat Shaded Polygons with Diffuse Reflection
35
Gouraud Shaded Polygons with Diffuse Reflection
36
Gouraud Shaded Polygons with Specular Reflection
37
Phong Shaded Polygons with Specular Reflection
38
Phong Shading of Curved Surfaces with Specular
Reflection
39
Improved Illumination Model and Multiple Lights
40
Texture Mapping
Write a Comment
User Comments (0)
About PowerShow.com