11.Illum
[prev][next]

Basic Concepts

Terms

illumination:calculating light intensity at a point (object space; equation) based loosly on physical laws
shading:algorithm for calculating intensities at pixels (image space; algorithm) (H & B uses surface rendering)

Objects

light sources -- light - emitting
other objects -- light - reflecting

Light sources

point (special case: at infinity)
distributed


Ambient Light

Ia = intensity of ambient light


Ambient Light

Ia = intensity of ambient light
ka = reflection coefficient
I = ka Ia = reflected intensity


Ambient Light

Ia = intensity of ambient light
ka = reflection coefficient
I = ka Ia = reflected intensity


Ambient Light

Ia = intensity of ambient light
ka = reflection coefficient
I = ka Ia = reflected intensity



Lambert's Law

Intensity of reflected light related to orientation


Lambert's Law

Intensity of reflected light related to orientation

Specifically:the radiant energy from any small surface area dA in any direction [theta] relative to the surface normal is proportional to cos [theta].


Lambert's Law

Intensity of reflected light related to orientation

Specifically:the radiant energy from any small surface area dA in any direction [theta] relative to the surface normal is proportional to cos [theta].



Diffuse Reflection



Diffuse Reflection


Idiff = kd Il cos [theta]


Diffuse Reflection


Idiff= kd Il cos [theta]
= kd Il (N . L)


Diffuse Reflection


Idiff= kd Il cos [theta]
= kd Il (N . L)
Itotal= ka Ia +kd Il (N . L)
- ambient -- diffuse -


Diffuse Reflection


Idiff= kd Il cos [theta]
= kd Il (N . L)
Itotal= ka Ia +kd Il (N . L)
- ambient -- diffuse -
Adding color (OdR, OdG, OdB)
=>
IR = IaR ka OdR + IlR kd OdR (N . L)
IG = IaG ka OdG + IlG kd OdG (N . L)
IB = IaB ka OdB + IlB kd OdB (N . L)


Diffuse Reflection

Idiff= kd Il cos [theta]
= kd Il (N . L)
Itotal= ka Ia +kd Il (N . L)
- ambient -- diffuse -
Adding color (OdR, OdG, OdB)
=>
IR = IaR ka OdR + IlR kd OdR (N . L)
IG = IaG ka OdG + IlG kd OdG (N . L)
IB = IaB ka OdB + IlB kd OdB (N . L)

for any wavelength t:It = Iat ka Odt + Ilt kd Odt (N . L)


Combined Model

I=Iamb+Idiff
=Iat ka Odt+Ilt kd (N . L) Odt

Combined Model with light source attenuation

I=Iamb+Idiff
=Iat ka Odt+fatt Ilt kd (N . L) Odt

where fatt = 1/dL2 - where dL is distance to light L


Combined Model with light source attenuation

I=Iamb+Idiff
=Iat ka Odt+fatt Ilt kd (N . L) Odt
where fatt = 1/dL2 or min( 1 / (C1 + C2 dL + C3 dL2), 1)
- where dL is distance to light L


far from light: little change
close to light: much change
=> accurate physically, but looks wrong

Combined Model with light source attenuation and atmospheric attenuation

I=Iamb+Idiff
=Iat ka Odt+fatt Ilt kd (N . L) Odt
where fatt = 1/dL2 or min( 1 / (C1 + C2 dL + C3 dL2), 1)
- where dL is distance to light L


far from light: little change
close to light: much change
=> accurate physically, but looks wrong

It' = So It + (1 - So) Idct

  • where Idct is the depth cue color
    • So = Sb + (Zo - Zb) (Sf - Sb) / (Zf - Zb)


Diffuse Shading Models

Flat Shading
Gouraud (interpolated) Shading


Flat Shading Algorithm

For each visible polygon
    evaluate illumination model with polygon normal

    For each scanline
	For each pixel on scanline
	    Fill with calculated intensity


The normal vector at vertex V is calculated as the average of the surface normals for each polygon sharing that vertex


COMPUTER GRAPHICS
Second Edition
by Hearn and Baker
@1995 by Prentice-Hall, Inc.
A Simon & Schuster Company
Englewood Cliffs, NJ 07632

Surface Normals

The normal vector at vertex V is calculated as the average of the surface normals for each polygon sharing that vertex


COMPUTER GRAPHICS
Second Edition
by Hearn and Baker
@1995 by Prentice-Hall, Inc.
A Simon & Schuster Company
Englewood Cliffs, NJ 07632

Vertex Normals

The normal vector at vertex V is calculated as the average of the surface normals for each polygon sharing that vertex


COMPUTER GRAPHICS
Second Edition
by Hearn and Baker
@1995 by Prentice-Hall, Inc.
A Simon & Schuster Company
Englewood Cliffs, NJ 07632


Gouraud Algorithm

For each visible polygon
    evaluate illumination model at vertices
       using vertex normals

    For each scanline
        calculate intensity at edge intersections
	    (span extrema) by linear interpolation

	For each pixel on scanline
	    calculate intensity by interpolation of
	        intensity at span extrema

(like scan conversion with vertex colors)


Gouraud Calculations


Gouraud Calculations

(1) calculate intensity at vertices (I1, I2, I3) from illumination model.


Gouraud Calculations

Ia = I1 - (I1 - I2) (y1 - ys)/(y1 - y2)

Ib = I1 - (I1 - I3) (y1 - ys)/(y1 - y3)

(1) calculate intensity at vertices (I1, I2, I3) from illumination model.

(2) interpolate vertex intensities along edges (Ia, Ib)


Gouraud Calculations

Ia = I1 - (I1 - I2) (y1 - ys)/(y1 - y2)

Ib = I1 - (I1 - I3) (y1 - ys)/(y1 - y3)

Ip = Ib - (Ib - Ia) (xb - xp)/(xb - xa)

(1) calculate intensity at vertices (I1, I2, I3) from illumination model.

(2) interpolate vertex intensities along edges (Ia, Ib)

(3) interpolate intensities at span extrema to pixels (Ip)



Problems with Interpolated Shading

(1) Polygon silhouette - edge still polygonal

(2) Perspective distortion - interpolation in screen space, rather than object space


Problems with Interpolated Shading

(1) Polygon silhouette - edge still polygonal

(2) Perspective distortion - interpolation in screen space, rather than object space

(3) Orientation dependence


Problems with Interpolated Shading

(1) Polygon silhouette - edge still polygonal

(2) Perspective distortion - interpolation in screen space, rather than object space

(3) Orientation dependence

(4) Problems at shared vertices

shading at P1 interpolated from at A & B
shading at P2 directly evaluated at C

Problems with Interpolated Shading

(1) Polygon silhouette - edge still polygonal

(2) Perspective distortion - interpolation in screen space, rather than object space

(3) Orientation dependence

(4) Problems at shared vertices

shading at P1 interpolated from at A & B
shading at P2 directly evaluated at C

(5) Unrepresentative vertex normals

actual surface undulates
vertex normals indicate flat surface


Combined Model

I = Iamb  + Idiff       + Ispec
  = ka Ia + kd Il (N.L) + ks Il (N.H)n

Combined Model With Multiple Lights

I = Iamb  + sum[i]( Idiff        + Ispec        ) for N lights
  = ka Ia + sum[i]( kd Ili (N.L) + ks Ili (N.H)n )

Combined Model With Multiple Lights

I[l] = Iamb[l]  + sum[i]( Idiff[l]        + Ispec[l]        ) for N lights
= ka[l] Ia[l] Od[l] + sum[i]( kd[l] Ili[l] (N.L) Od[l] + ks[l] Ili[l] (N.H)n )
(* [l] - lambda)

No specular color given => highlights light color (plastic)


Combined Model With Multiple Lights and Metallic Highlights

I[l] = Iamb[l]  + sum[i]( Idiff[l]        + Ispec[l]        ) for N lights
= ka[l] Ia[l] Od[l] + sum[i]( kd[l] Ili[l] (N.L) Od[l] + ks[l] Ili[l] (N.H)n Od[l] )
(* [l] - lambda)

For metallic highlights, specular reflection must be wavelength dependent.


Combined Model With Multiple Lights and Metallic Highlights

I[l] = Iamb[l] + sum[i]( Idiff[l] + Ispec[l] ) for N lights
= ka[l] Ia[l] Od[l] + sum[i]( kd[l] Ili[l] (N.L) Od[l] + ks[l]([l], [t]) Ili[l] (N.H)n Od[l] )

For even more accurate highlights, specular reflection coefficient depends on both wavelength and angle of incidence Ks([l], [t]).

(* [l] - lambda, [t] - theta)

Combined Model With Multiple Lights, Metallic Highlights and Distance Attenuation

I[l] = Iamb[l] + sum[i]( Idiff[l] + Ispec[l] ) for N lights
= ka[l] Ia[l] Od[l] + sum[i]( f(di)( kd[l] Ili[l] (N.L) Od[l] + ks[l]([l], [t]) Ili[l] (N.H)n Od[l] ) )

Where di is distance to light i

Possible f(di) = 1 / (a0 + a1 di + a2 di2)

a1 di - linear falloff
a2 di2 - quadratic falloff

(* [l] - lambda, [t] - theta)


Specular Reflection


Specular Reflection

Ispec = ks Il cosn[phi]

where:
ks = specular reflection coefficient
n = specular exponent


Specular Reflection

Ispec = ks Il cosn[phi]
= ks Il (R.V)n

where:
ks = specular reflection coefficient
n = specular exponent


Specular Reflection

For specific wavelength:

Ispec[l] = ks[l] Il cosn[phi]
= ks[l] Il (R.V)n

=> Not dependent on surface color -> white highlights


Specular Reflection

For specific wavelength:

Ispec[l] = ks[l] Il Os[l] cosn[phi]
= ks[l] Il Os[l] (R.V)n

=> colored highlights


Specular Reflection

(* based on empirical observations)

Specular Reflection

(* based on empirical observations)

Specular Reflection

(* based on empirical observations)


Calculating Reflection Vector

where L and N are unit length

Calculating Reflection Vector

where L and N are unit length

R is L mirrored about N


Calculating Reflection Vector

where L and N are unit length
=> projection of L on N is
N cos [theta]

S = N cos [theta] - L

R is L mirrored about N


Calculating Reflection Vector

where L and N are unit length
=> projection of L on N is
N cos [theta]

S = N cos [theta] - L

R is L mirrored about N
R = N cos [theta] + S = 2N cos [theta] - L


Calculating Reflection Vector

where L and N are unit length
=> projection of L on N is
N cos [theta]

S = N cos [theta] - L

R is L mirrored about N
R = N cos [theta] + S = 2N cos [theta] - L
= 2N (N.L) - L => where Ispec = ks Il ( (2N (N.L) - L ).V )n
(2N (N.L) - L ).V = R.V


Calculating Reflection Vector

where L and N are unit length
=> projection of L on N is
N cos [theta]

S = N cos [theta] - L

R is L mirrored about N
R = N cos [theta] + S = 2N cos [theta] - L
= 2N (N.L) - L => where Ispec = ks Il ( (2N (N.L) - L ).V )n
(2N (N.L) - L ).V = R.V

Alternatively: use halfway vector H
H = (L + V) / |L + V|


Calculating Reflection Vector

where L and N are unit length
=> projection of L on N is
N cos [theta]

S = N cos [theta] - L

R is L mirrored about N
R = N cos [theta] + S = 2N cos [theta] - L
= 2N (N.L) - L => where Ispec = ks Il ( (2N (N.L) - L ).V )n
(2N (N.L) - L ).V = R.V = cos [phi]

Alternatively: use halfway vector H
H = (L + V) / |L + V| = { direction of maximum highlights }

maximum highlight when H = N (because then R = V)
=> Ispec = ks Il (H.N)n
H.N = cos [alpha]


Calculating Reflection Vector

where L and N are unit length
=> projection of L on N is
N cos [theta]

S = N cos [theta] - L

R is L mirrored about N
R = N cos [theta] + S = 2N cos [theta] - L
= 2N (N.L) - L => where Ispec = ks Il ( (2N (N.L) - L ).V )n
(2N (N.L) - L ).V = R.V = cos [phi]

Alternatively: use halfway vector H
H = (L + V) / |L + V| = { direction of maximum highlights }

maximum highlight when H = N (because then R = V)
=> Ispec = ks Il (H.N)n
H.N = cos [alpha]

Two methods:

  • can give different results ( [alpha] != [theta] )
  • H is faster to compute when viewer and light at infinity (constant H)



Advanced Point Lights: Warn Model

Concept: control light direction with hypothetical reflecting surface (only specular)


Advanced Point Lights: Warn Model

Concept: control light direction with hypothetical reflecting surface (only specular)

Light intensity affected by pseudosurface orientation
IL[alpha] = IL'[alpha] cos Pr
where:

  • p = pseudosurface specular exponent
  • r = angle between L and L'

  • Advanced Point Lights: Warn Model

    Concept: control light direction with hypothetical reflecting surface (only specular)

    Light intensity affected by pseudosurface orientation
    IL[alpha] = IL'[alpha] cos Pr
    where:

  • p = pseudosurface specular exponent
  • r = angle between -L and L'
  • = IL'[alpha] (-L.L')P


    Advanced Point Lights: Warn Model

    Flaps and cones mimic photographic light characteristics



    Phong Shading


    Phong Shading

    (approximation to curved surface)
    Ideally: shade from normals of curved surface


    Phong Shading

    where Pa, Pb, Pc are pixels covered by this polygon

    (approximation to curved surface)
    Ideally: shade from normals of curved surface

    Approximate with normals interpolated between vertex normals:
    Na = | Pa - P0 | / | P1 - P0 | N1 + | P1 - Pa | / | P1 - P0 | N0



    Phong Algorithm

    For each visible polygon
      For each scanline
        Calculate normals at edge intersections (span
               extrema) by linear interpolation
    
        For each pixel on scanline
          Calculate normal by interpolation of normals
    	   at span extrema
    
          Evaluate illumination model with that normal
    
    


    Filtered Transparency


    Filtered Transparency

    I[f] = I[f]1 + kt1 Ot[f] I[f]2

    Must composite back to front (or front to back)



    Refractive Transparency


    Refractive Transparency



    Calculating Refraction Vector


    Calculating Refraction Vector


    Calculating Refraction Vector


    Calculating Refraction Vector

    T = sin [theta]rM - cos[theta]rN


    Calculating Refraction Vector

    T = sin [theta]rM - cos[theta]rN


    Calculating Refraction Vector

    T = sin [theta]rM - cos[theta]rN
    = sin[theta]r / sin[theta]i (N cos[theta]i - L) - cos[theta]r N


    Calculating Refraction Vector

    T = sin [theta]rM - cos[theta]rN
    = sin[theta]r / sin[theta]i (N cos[theta]i - L) - cos[theta]r N
    =( (ni / nr) sin[theta]i ) / sin[theta]i (N cos[theta]i - L) - cos[theta]r N


    Calculating Refraction Vector

    T = sin [theta]rM - cos[theta]rN
    = sin[theta]r / sin[theta]i (N cos[theta]i - L) - cos[theta]r N
    =( (ni / nr) (N cos[theta]i - L) - cos[theta]r N
    = ((ni / nr) cos[theta]i - cos[theta]r) N - (ni / nr) L


    Calculating Refraction Vector

    T = sin [theta]rM - cos[theta]rN
    = sin[theta]r / sin[theta]i (N cos[theta]i - L) - cos[theta]r N
    =( (ni / nr) (N cos[theta]i - L) - cos[theta]r N
    = ((ni / nr) cos[theta]i - cos[theta]r) N - (ni / nr) L
    = ((ni / nr) cos[theta]i - sqrt(1 - (ni / nr)2 sin2[theta]i) N - (ni / nr) L


    Calculating Refraction Vector

    T = sin [theta]rM - cos[theta]rN
    = sin[theta]r / sin[theta]i (N cos[theta]i - L) - cos[theta]r N
    =( (ni / nr) (N cos[theta]i - L) - cos[theta]r N
    = ((ni / nr) cos[theta]i - cos[theta]r) N - (ni / nr) L
    = ((ni / nr) cos[theta]i - sqrt(1 - (ni / nr)2 sin2[theta]i) N - (ni / nr) L
    = ((ni / nr) (N.L) - sqrt(1 - (ni / nr)2 (N.L)2) N - (ni / nr) L



    Light Source Energy


    Light Source Energy

    Illumination from a light source depends on the solid angle [omega] subtended by that light source

    [omega] = [integral]2[pi] ( [integral]tan-1(r's / r0) ( sin [theta] d[theta] d[phi] ) ) = 2[pi] (1 - cos (tan-1 rs/r0))


    Light Source Energy

    Illumination from a light source depends on the solid angle [omega] subterded by that light source

    [omega] = [integral]2[pi] ( [integral]tan-1(r's / r0) ( sin [theta] d[theta] d[phi] ) ) = 2[pi] (1 - cos (tan-1 rs/r0))
    sometimes approximated by
    = [pi] rs/r0 when rs/r0 << 1


    Light Source Energy

    Illumination from a light source depends on the solid angle [omega] subterded by that light source

    [omega] = [integral]2[pi] ( [integral]tan-1(r's / r0) ( sin [theta] d[theta] d[phi] ) ) = 2[pi] (1 - cos (tan-1 rs/r0))
    sometimes approximated by
    = [pi] rs/r0 when rs/r0 << 1

    Incident energy:
    El = Il (N.L) d[omega]



    Surface physics

    Smooth dielectric (like glass)


    Surface physics

    Rough dielectric (like glass)


    Surface physics

    Smooth conductor (like metal)


    Surface physics

    Rough conductor (like metal)


    Surface physics


    scattering by pigment

    Composite (like plastic)



    Bidirectional Reflectance


    Bidirectional Reflectance

    Reflected light is related to incident light
    I = p E e
    where:

  • p is ratio of reflected intensity for a given direction to incident energy from another
    = bidirectional reflectance

  • Bidirectional Reflectance

    Reflected light is related to incident light
    I = p E e
    where:

  • p is ratio of reflected intensity for a given direction to incident energy from another
    = bidirectionalreflectance
  • Cook - Torrance Illumination Model:
    I = f ka pa Ia + sum[i] (Ili (N.L) d[omega]i (kd pd + ks ps)
    where:

  • f is unblocked fraction of hemisphere
  • ka, kd, ks are properties of material


  • Geometric Attenuation


    No interference

    shadowing

    masking

    For rought surfaces
    consider surface to be made of microfacets
    calculate reflections from microfacets


    Geometric Attenuation


    No interference

    shadowing

    masking

    Torrance - Sparrow model:
    ps = F/[pi] (D.G)/ ( (N.L) (N.S) )
    where:

  • F is fresnel term for wavelength dependence
  • D is distribution function for microfacets
  • G is geometric attenuation factor


  • Bump Mapping


    Bump Mapping

    Straight Phong Shading

    => approximates smoothly curved surface


    Bump Mapping

    Straight Phong Shading

    => approximates smoothly curved surface

    Phong with bump mapping


    Bump Mapping

    Straight Phong Shading

    => approximates smoothly curved surface

    Phong with bump mapping

    => approximates bumpy surface



    Environmental Mapping

    Projecting a pixel area to a surface, then reflecting the area to the environment map.


    Environmental Mapping

    Projecting a pixel area to a surface, then reflecting the area to the environment map.



    Texture Mapping


    Texture mapping from pixel to the surface to the texture map.


    Texture Mapping


    Texture mapping from pixel to the surface to the texture map.

    For each pixel
    

    Texture Mapping


    Texture mapping from pixel to the surface to the texture map.

    For each pixel
      determine position on object surface for
         each pixel corner (use inverse viewing 
         transformation)
    

    Texture Mapping


    Texture mapping from pixel to the surface to the texture map.

    For each pixel
      determine position on object surface for
         each pixel corner (use inverse viewing 
         transformation)
    
      determine position in texture map for 
         each pixel corner
    

    Texture Mapping


    Texture mapping from pixel to the surface to the texture map.

    For each pixel
      determine position on object surface for
         each pixel corner (use inverse viewing 
         transformation)
    
      determine position in texture map for 
         each pixel corner
    
      get color (or average color) from 
         texture map
    

    Texture Mapping


    Texture mapping from pixel to the surface to the texture map.

    For each pixel
      determine position on object surface for
         each pixel corner (use inverse viewing 
         transformation)
    
      determine position in texture map for 
         each pixel corner
    
      get color (or average color) from 
         texture map
    
      map color back onto screen pixel
    


    [prev][next]
    Made by dynaPage 0.2