CS430 Computer Graphics - PowerPoint PPT Presentation

About This Presentation
Title:

CS430 Computer Graphics

Description:

Specular reflections. Incident light does not ... Specular components ... Use to calculate the falloff of specular intensity as has the same property as ... – PowerPoint PPT presentation

Number of Views:149
Avg rating:3.0/5.0
Slides: 28
Provided by: ChiChe7
Learn more at: https://cs.winona.edu
Category:

less

Transcript and Presenter's Notes

Title: CS430 Computer Graphics


1
CS430 Computer Graphics
  • Lighting and Shading

2
Topics
  • Introduction
  • Geometric Model in Lighting
  • Colored Surfaces and Lights
  • Shading and Graphics Pipeline
  • Flat Shading and Smooth Shading

3
Introduction
  • Lighting
  • Process of computing the luminous intensity
    reflected from a specific 3-D point
  • Shading
  • Process of assigning colors to pixels
  • Shading model dictates how light is scattered or
    reflected from a surface
  • We will begin with achromatic light then colored
    lights

4
Introduction
  • Two types of light sources
  • Point light source
  • Ambient light
  • Light interacts surfaces in different ways
  • Absorbed by surface
  • Reflected by surface
  • Transmitted into the interior
  • What absorbs all of the incident achromatic light?

5
Introduction
  • Types of reflection of incident light
  • Diffuse scattering
  • Some of the incident light penetrates the surface
    slightly and is re-radiated uniformly in all
    directions
  • Scattering light interacts strongly with surface
    ? color is affected by nature of surface material
  • Specular reflections
  • Incident light does not penetrate the surface
  • Reflected directly from the surface
  • More mirror like and highly directional
  • Highlight, shiny, plastic like

6
Introduction
  • Total light reflected from the surface in a
    certain direction is the sum of
  • Diffuse components
  • Specular components
  • We calculate the size of each component that
    reaches the eye for each point of interest on
    surfaces

7
Geometric Model in Lighting
  • Principle vectors to find amount of light
    reaching the eye from a point P
  • m normal vector of surface at P
  • v from P to the eye
  • s from P to light source
  • Angles between vectors are
  • calculated in the world
  • coordinates
  • Is intensity of light source

m
eye
s
v
P
8
Diffuse Component
  • Id intensity of the diffused component
  • Scattering is uniform in all directions
  • Independent of v
  • unless m ? v ? 0, where Id 0 (why?)
  • Lamberts law brightness is proportional to the
    area subtended ( fraction cos(?))
  • ? ? 0 brightness varies slightly with angle
  • ? ? 90 brightness falls rapidly to 0

m
s
?
9
Diffuse Component
  • cos(?)
  • How do we calculate/obtain the value for ?d ? By
    experiments.

10
Specular Reflection
  • Isp intensity of specular reflection
  • Phong model is used to approximate highlight
  • Amount of light reflected is greatest in the
    direction of perfect mirror reflection, r
  • Amount of light reflected diminished rapidly at
    the nearby angles
  • Beam pattern

r
m
s
P
11
Specular Reflection
  • Remember ?
  • Amount of light reflected falls off as ?
    increases and is approximately cosf(?), where f
    is the Phong exponent
  • Problem expensive to compute as r has to be
    found and normalized

r
m
s
eye
?
v
12
Specular Reflection
  • Solution (proposed by Jim Blinn)
  • Calculate h s v
  • Let ? be the angle between h and m
  • Use ? to calculate the falloff of specular
    intensity as ? has the same property as ?
  • ? ? ?, but can be compensated by different value
    of f

13
Ambient Light
  • A uniform background glow in the environment
  • Source is not situated at any particular place
  • Light spreads uniformly in all directions
  • Ia intensity of light source
  • Ia?a is added to the light reaching the eye
  • ?a ambient reflection coefficient
  • ?a is often the same as ?d

14
Combining Light Contributions
  • I Ia ?a Id ?d ? lambert Isp ?s ? phongf
  • lambert
  • phong
  • Implications for different points P on a facet
  • Ambient is not changed for different P
  • m is the same for all point on the facet
  • If the light is far far away, s will change
    slightly as P changes ? diffuse will change
    slightly on different P
  • If the light or/and eye is/are close, s and h
    will change a lot as P changes ? specular changes
    significantly over the facet

15
Colored Surfaces and Lights
  • Colored surface
  • Ir Iar ?ar Idr ?dr ? lambert Ispr ?sr ?
    phongf
  • Ig Iag ?ag Idg ?dg ? lambert Ispg ?sg ?
    phongf
  • Ib Iab ?ab Idb ?db ? lambert Ispb ?sb ?
    phongf
  • lambert and phong terms do not depends on color
    component
  • We have to define 9 reflection coefficients
  • Ambient and diffuse reflection are based on the
    color of surface

16
Colored Surfaces and Lights
  • Colored light (Isr, Isg, Isb)
  • If the color of a surface is (r, g, b), then it
    is reasonable to set
  • (?ar, ?ag, ?ab) (?dr, ?dg, ?db) (rK, gK,
    bK), where K is the fraction of light reflected
  • The diffusion of the surface
  • (Isr?dr, Isg?dg, Isb?db) (IsrrK, IsggK,
    IsbbK)
  • Example white light
  • Isr Isg Isb I, (r, g, b) (0.3, 0.45,
    0.25) then diffusion (0.3IK, 0.45IK, 0.25IK) ?
    the surface is seen as its color

17
Colored Surfaces and Lights
  • Color of specular light
  • Often the same as that of light source
  • Example sunlight
  • Highlight on plastic caused by sunlight is white
  • Set (?sr, ?sg, ?sb) (?s, ?s, ?s)
  • ?s 0.5 ? slightly shiny
  • ?s 0.9 ? highly shiny
  • Different coefficients are selected for specific
    materials. (Fig 8.17)

18
(No Transcript)
19
Shading and Graphics Pipeline
  • Vertices are sent down the pipeline along with
    their associated normals
  • All shading calculations are done on vertices

v1, m1
v2, m2
projection matrix
viewport matrix
VM
clip
v0, m0
shading is applied here
20
Shading and Graphics Pipeline
  • Lights are objects and the positions of light
    sources are also transformed by the modelview
    matrix
  • After all quantities are expressed in camera
    coordinates, colors are attached to vertices
    using the formula
  • If an object is clipped, normals of newly
    generated vertices are calculated by interpolation

21
Flat Shading and Smooth Shading
  • Polygonal face in 3D space
  • Individual face
  • Underlying surface approximated
  • Shading methods
  • Flat shading
  • Smooth shading
  • Gouraud shading
  • Phong shading

22
Comparison of Shading Methods
23
Flat Shading
  • Entire face is drawn with the same color
  • Lateral inhibition
  • When there is a discontinuity across an object,
    the eye manufactures a Mach band at the
    discontinuity and a vivid edge is seen
  • Specular highlights are rendered poorly
  • Either no highlight at all
  • Or highlight on the entire face

24
Smooth Shading
  • Smooth shading computes colors at more points on
    each face to de-emphasize edges between adjacent
    faces
  • Use linear interpolation
  • Gouraud shading
  • Interpolate vertex colors
  • Phong shading
  • Interpolate vertex normals
  • Interpolate normal for each pixel

25
Gouraud Shading
  • Used by OpenGL
  • Example
  • colora by interpolating
  • color3 and color4
  • colorb by interpolating
  • color1 and color2
  • Colors of pixels on the horizontal line segment
    is obtained by interpolating colora and colorb
  • Does not picture highlights well

color3
color2
colora
colorb
color4
color1
26
Phong Shading
  • Compute normal at each pixel by interpolating the
    normals at the vertices
  • Apply the shading model to to every point to find
    the color
  • Example
  • ma by interpolating m3 and m4
  • mb by interpolating m1 and m2
  • Normals of pixels on the
  • horizontal line segment is
  • obtained by interpolating ma and mb
  • Colors of the pixels are then computed

m3
m2
ma
mb
m4
m1
27
Phong Shading
  • Very smooth appearance
  • Highlights are approximated better
  • Principle drawback
  • Heavy computation ? slow speed
  • Not supported by OpenGL
  • Can be approximated using texture mapping
  • Phong shading ? Phong model

Dont be confused!!
Write a Comment
User Comments (0)
About PowerShow.com