Illumination, Lighting and Shading Model - PowerPoint PPT Presentation

1 / 39
About This Presentation
Title:

Illumination, Lighting and Shading Model

Description:

Illumination: the transport of energy (in particular, the ... Some not-too-complicated affine analysis shows : If A is a matrix for transforming points, ... – PowerPoint PPT presentation

Number of Views:193
Avg rating:3.0/5.0
Slides: 40
Provided by: pradondet
Category:

less

Transcript and Presenter's Notes

Title: Illumination, Lighting and Shading Model


1
Illumination, Lighting and Shading Model
  • Pradondet Nilagupta
  • Dept. of Computer Engineering
  • Kasetsart University

2
Definitions (1/2)
  • Illumination the transport of energy (in
    particular, the luminous flux of visible light)
    from light sources to surfaces points
  • Note includes direct and indirect illumination
  • Lighting the process of computing the luminous
    intensity (i.e., outgoing light) at a particular
    3-D point, usually on a surface
  • Shading the process of assigning colors to pixels

3
Definitions (2/2)
  • Illumination models fall into two categories
  • Empirical simple formulations that approximate
    observed phenomenon
  • Physically-based models based on the actual
    physics of light interacting with matter
  • We mostly use empirical models in interactive
    graphics for simplicity
  • Increasingly, realistic graphics are using
    physically-based models

4
Lighting Model
  • Many different models exist for simulating
    lighting reflections
  • Most models break lighting into constituent parts
  • ambient reflections
  • diffuse reflections
  • specular highlights

5
Lighting Model Component
  • Material Properties
  • used to describe an objects reflected colors
  • Surface Normals
  • Light Properties
  • used to describe a lights color emissions
  • Light Model Properties
  • global lighting parameters

6
Components of Illumination
  • Surface properties
  • Reflectance spectrum (i.e., color of the surface)
  • Geometric attributes
  • Position
  • Orientation
  • Micro-structure
  • Light sources (or emitters)
  • Spectrum of emittance (i.e, color of the light)
  • Geometric attributes
  • Position
  • Direction
  • Shape
  • Directional attenuation

7
Ambient Light Sources
  • Objects not directly lit are typically still
    visible
  • E.g., the ceiling in this room, undersides of
    desks
  • This is the result of indirect illumination from
    emitters, bouncing off intermediate surfaces
  • Too expensive to calculate (in real time)

Ireflected kambient Iambient
8
Directional Light Sources
  • all rays of light from the source are parallel
  • As if the source is infinitely far away from the
    surfaces in the scene
  • A good approximation to sunlight
  • direction is constant for all surfaces in the
    scene

9
Point Light Sources
  • A point light source emits light equally in all
    directions from a single point
  • The direction to the light from a point on a
    surface thus differs for different points

10
Other Light Sources
  • Spotlights are point sources whose intensity
    falls off directionally.
  • Supported by OpenGL
  • Area light sources define a 2-D emissive surface
    (usually a disc or polygon)
  • Good example fluorescent light panels

11
Reflection
  • Ambient Reflections
  • Diffuse Reflection
  • Specular Reflections

12
Ambient Reflections
  • Color of an object when not directly illuminated
  • Think about walking into a room with the curtains
    closed and lights off

13
Diffuse Reflections
  • Color of an object when directly illuminated
  • often referred to as base color
  • The angle between the surface normal and the
    incoming light is the angle of incidence
  • Idiffuse kd Ilight cos ?
  • In practice we use vector arithmetic
  • Idiffuse kd Ilight (n l)

14
Specular Reflections
  • Shiny surfaces exhibit specular reflection
  • Polished metal
  • Glossy car finish
  • A light shining on a specular surface causes a
    bright spot known as a specular highlight

15
Phong Lighting Model
  • Using surface normal
  • OpenGLs lighting model based on Phongs

16
OpenGL Material Properties
  • GL_AMBIENT
  • GL_DIFFUSE
  • GL_SPECULAR
  • GL_SHININESS
  • GL_EMISSION

17
Computing Surface Normals
  • Lighting needs to know how to reflect light off
    the surface
  • Provide normals per
  • face - flat shading
  • vertex - Gouraud shading
  • pixel - Phong shading
  • OpenGL does not support Phong natively

18
Face Normals
  • Same normal for all vertices in a primitive
  • results in flat shading for primitive

glNormal3f( nx, ny, nz ) glBegin( GL_TRIANGLES
) glVertex3fv( v1 ) glVetrex3fv( v2 )
glVertex3fv( v3 ) glEnd()
19
Computing Face Normals ( Polygons )
  • Were using only planar polygons
  • Can easily compute the normal to a plane
  • use a cross product

20
Computing Face Normals ( Algebraic )
  • For algebraic surfaces, compute
  • where

21
Vertex Normals
  • Each vertex has its own normal
  • primitive is Gouraud shaded basedon computed
    colors

glBegin( GL_TRIANGLES ) glNormal3fv( n1 )
glVertex3fv( v1 ) glNormal3fv( n2 )
glVetrex3fv( v2 ) glNormal3fv( n3 )
glVertex3fv( v3 ) glEnd()
22
Computing Vertex Normals (Algebraic )
  • For algebraic surfaces, compute

23
Computing Vertex Normals ( Polygons )
  • Need two things
  • face normals for all polygons
  • know which polygons share a vertex

24
Sending Normals to OpenGL
  • glNormal3f( x, y, z )
  • Use between glBegin() / glEnd()
  • Use similar to glColor()

25
Normals and Scale Transforms
  • Normals must be normalized
  • non-unit length skews colors
  • Scales affect normal length
  • rotates and translates do not
  • glEnable( GL_NORMALIZE )

26
Why?
  • Lighting computations are really done in eye
    coordinates
  • this is why there are the projection and
    modelview matrix stacks
  • Lighting normals transformed by the inverse
    transpose of the ModelView matrix

27
Flat Shading
  • The simplest approach, flat shading, calculates
    illumination at a single point for each polygon
  • If an object really is faceted, is this accurate?
  • No
  • For point sources, the direction to light varies
    across the facet
  • For specular reflectance, direction to eye varies
    across the facet

28
Flat Shading
  • We can refine it a bit by evaluating the Phong
    lighting model at each pixel of each polygon, but
    the result is still clearly faceted
  • To get smoother-looking surfaceswe introduce
    vertex normals at eachvertex
  • Usually different from facet normal
  • Used only for shading (as opposed to what?)
  • Think of as a better approximation of the real
    surface that the polygons approximate (draw it)

29
Vertex Normals
  • Vertex normals may be
  • Provided with the model
  • Computed from first principles
  • Approximated by averaging the normals of the
    facets that share the vertex

30
Gouraud Shading
  • This is the most common approach
  • Perform Phong lighting at the vertices
  • Linearly interpolate the resulting colors over
    faces
  • This is what OpenGL does
  • Demo at http//www.cs.virginia.edu/cs551/vrml/tpo
    t.wrl
  • Does this eliminate the facets?

31
Phong Shading
  • Phong shading is not the same as Phong lighting,
    though they are sometimes mixed up
  • Phong lighting the empirical model weve been
    discussing to calculate illumination at a point
    on a surface
  • Phong shading linearly interpolating the surface
    normal across the facet, applying the Phong
    lighting model at every pixel
  • Same input as Gouraud shading
  • Usually very smooth-looking results
  • But, considerably more expensive

32
An Aside Transforming Normals
  • Irritatingly, the matrix for transforming a
    normal vector is not the same as the matrix for
    the corresponding transformation on points
  • In other words, dont just treat normals as
    points

33
Transforming Normals
  • Some not-too-complicated affine analysis shows
  • If A is a matrix for transforming points,then
    (AT)-1 is the matrix for transforming normals
  • When is this the same matrix?
  • What is homogeneous representation of a vector
    (as opposed to a point?)
  • Can use this to simplify the problem only upper
    3x3 matrix matters, so use only it
  • More detail in FvD Appendix A.5

34
Texture Mapping Motivation
  • Scenes created with diffuse lighting look
    convincingly three-dimensional, but are flat,
    chalky, and cartoonish
  • Phong lighting lets us simulate materials like
    plastic and (to a lesser extent) metal, but
    scenes still seem very cartoonish and unreal
  • Big problem polygons are too coarse-grained to
    usefully model fine surface detail
  • Solution texture mapping

35
Texture Mapping Motivation
  • Adding surface detail helps keep CG images from
    looking simple and sterile
  • Explicitly modeling this detail in geometry can
    be very expensive
  • Zebra stripes, wood grain, writing on a
    whiteboard
  • Texture mapping pastes images onto the surfaces
    in the scene, adding realistic fine detail
    without exploding the geometry

36
Texture Mapping Examples
37
Texture Mapping Fundamentals
  • A texture is typically a 2-D image
  • Image elements are called texels
  • Value stored at a texel affects surface
    appearance in some way
  • Example diffuse reflectance, shininess,
    transparency
  • The mapping of the texture to the surface
    determines the correspondence, i.e., how the
    texture lies on the surface
  • Mapping a texture to a triangle is easy (why?)
  • Mapping a texture to an arbitrary 3-D shape is
    more complicated (why?)

38
Texture Mapping Rendering
  • Rendering uses the mapping
  • Find the visible surface at a pixel
  • Find the point on that surface corresponding to
    that pixel
  • Find the point in the texture corresponding to
    that point on the surface
  • Use the parameters associated with that point on
    the texture to shade the pixel

39
Texture Mapping Basics
  • We typically parameterize the texture as a
    function in (u, v)
  • For simplicity, normalize u v to 0, 1
  • Associate each triangle with a texture
  • Give each vertex of the triangle a texture
    coordinate (u, v)
  • For other points on the triangle, interpolate
    texture coordinate from the vertices
  • Much like interpolating color or depth
  • But theres a catch...
Write a Comment
User Comments (0)
About PowerShow.com