CS代考计算机代写 algorithm CS580


Illumination and Shading
Ulrich Neumann
Computer Graphics Rendering

Illumination and shading
Illumination (lighting) and shading
models simulation of light interactions with scene
light sources, geometry, propagation, interaction with surfaces, imaging process in camera

Shading Examples
Images courtesy of Watt, Watt & Watt, and Foley & van Dam

Global versus Local Illumination

Indirect Illumination

Global versus Local Illumination
Global Illumination
Models indirect illumination and occlusions
Local Illumination
Only models
direct illumination
No reflection
No refraction
No shadows

Global versus Local Illumination
Local illumination is a simplified model in which every pixel color is only a function of parameters at that one surface point.
Shadows are based on light visibility.
Inter-reflections are based on reflection path.
Every pixel color is a function of entire scene.
Local Illumination
Global Illumination

Fidelity of Global Illumination
Global illumination effects are modeled with varying degrees of fidelity. Algorithms may produce simple approximations or complex diffusion and shadow effects.
Simple shadows result from binary light visibility tests
Light diffusion produces soft shadows

Light Terminology
Radiant Intensity (I = W/sr)
Illuminating energy emitted by a light source
Irradiance or Illuminance (E = W/m2 )
Light energy falling on a surface area
Radiance or Luminance (L = W/m2/sr)
Light energy reflected by a surface area

Light Source Radiant Intensity
Radiant Intensity per steradian
Ie = power/sr (Watts/steradian)
constant in vacuum at all distances
Ie is constant over distance for a
fixed solid-angle
sr = surface area (a) of portion of sphere divided by r2
sr = a/r2
Area of sphere surface = 4 pi r2
sr = (4pi r2)/r2 sr = 4pi steradians over sphere of any radius
E = Watt/m2
Energy hitting a surface
Radiance or Power Density
diminishes with “square” of
distance from source

Ie = Power over these areas – a fixed solid-angle

Light Color and Intensity
Ie is specified as coefficients of color spectrum or basis function (RGB, HSV…)
Ie = (R,G,B) | R,G,B  [0,1]
three color channels model colored light
Based on human perception (next slide)
arbitrary scale and units
e.g., Ie = (0.1, 0.6, 0.9)
“Color” of light is determined by the
relative levels of RGB intensities
“Brightness” is determined by aggregate or sum of RGB intensities

Color and Perception
Natural light has energy over a
continuous spectrum
We perceive “color”
based on energy
at different frequencies
Energy vs freq histogram
Human eyes have 3 “cone”
sensors that have peaked
sensitivities over different
frequency ranges
3 dimensions (trivariant)
color perception

Color Metamers
Two different spectrums may look like the same color to us since we only sense the levels of three sensor ranges
Differing spectrums that produce the same perceived color are called metamers
RGB color produces a range of perceived colors
that are metamers for
natural light spectrums
What matters is that the three
cone sensors produce the
same brain signals
Metamers are the basis for all
display (and print) technologies
that produce a range of colors
from a mix of basis colors

Light interaction in medium or camera
Atmosphere effect, lens effects

We use simple approximations
vacuum – no haze, smoke, thermal shimmer
opaque scene objects – no transparency
ideal camera imaging – no lens flare, color

FYI: Papers by Ron Henry (USC)
Color Perception through Atmospheric Haze

These are global effects that require
more complex models of lighting,
shading, and cameras than
used for HWs

Modeling Light Source Geometry
Geometry parameters that affect illumination of a scene
Size and shape
Position and orientation
Directional distribution

Ie = f() Directional distribution of intensity can vary for a point-source or a region of an area light-source
Occlusions in the light source structure also modify the intensity and distribution of light energy over different regions in the scene

A large-area source can be approximated
as multiple uniform-intensity regions that
each contribute independently to the scene
Light is addative so complex sources can be
decomposed into a sum of simpler sources

When the source and scene-areas are
small (relative to distance between source and scene), incident intensity can be approximated as a uniform fixed-direction distribution
a far-away source produces a uniform illumination over a scene

Simplified Lighting
The total irradiance E falling on some surface area of a scene requires integral of Ie function over visible hemisphere (prior slide)
even fairly simple cases can be difficult to compute

For simplicity (for HW4) … assume distant point-light sources (e.g., sun, or light bulb in a large room)
Source has uniform radial intensity distribution
E = ~ constant within distances in scene – neglect distance falloff
Solid angle per unit surface area is ~ constant everywhere
Direction to source is constant within scene

This simple approximation of actual physics only requires two parameters to define a light
direction (x,y,z) – vector from surface to light source
intensity (r,g,b) of the light

Irradiance Geometry
Irradiance E: Incident radiant energy per unit area

Diminishes with the cosine of the incident angle

I(x, w) is the light intensity arriving from all directions and entering hemisphere Ω over unit surface area.

Interaction with opaque surfaces
Light hitting an opaque surface reflects a fraction of that light back into the environment.
Two extremes are observed

Mirrors – specular reflection
Incoming ray reflects about
the surface’s normal
perfect mirror has no scattering – just perfect reflection
color shift is possible by attenuation of RGB components

Ideal white chalk – diffuse reflection
Incoming ray scatters equally in all directions (ideal case)
color shift is possible by attenuation of RGB components

Ideal Specular Reflection
Reflection occurs in the “mirror” direction
L is reflected about the normal vector (N) to create R

Ij = Ie Ks Reflected light is attenuated (colored) by Ks
Ks is RGB vector of “specular color” coefficients [0,1]
Ie and Ij are both RGB color intensity values in their respective vector directions L and R

General Specular Model
Reflection occurs mainly in the “mirror” R direction, but there is some spread in similar directions V (view vector)
Ij(V) = Ie Ks (V•R)spec is the reflected specular intensity in the direction of vector V (for normalized V and R)

Specular reflection is attenuated (colored) by Ks and by the angle between R and V
“spec” exponent controls the
distribution of intensity about R

Ie and Ij(V) are both RGB color intensity values in their respective vector directions L and V
Angle of R and V
(V • R)spec
n = spec

Specular Power
Ij(V) = Ie Ks (V•R)spec
“spec” exponent controls the distribution of energy about R

These images show it’s effect:

Higher values of “spec” produce
smaller, tighter specular
highlights that also make
surfaces appear smoother



Ideal Diffuse Reflection
Reflection or scattering is equal in all directions
for all wavelengths
Rho (ρ) is the ratio of output intensity (in any direction) to input intensity

models the case where L and N are coincident and the surface scatters all wavelengths equally

Colored Diffuse Absorption
Reflected intensity Ij = Ie Kd in any direction over the exit hemisphere
Still restricted to case where N and L are coincident
Kd models the absorption (color) of a surface
Kd is RGB vector of “diffuse color” coefficients [0,1] that scale light source Ie RGB components

Ij and Ie are RGB color intensity vectors

General Diffuse Model
In the more general case where the direction L varies
Ij = Ie Kd cos() or Ij = Ie Kd (L•N)
cos() accounts for the change in projected surface area of incident light Ie and surface orientation toward/away from light
L•N computes cos () function if L and N are normalized vectors
For either formulation, surfaces facing away from light receive NO illumination
For ||  || > 90, cos term is clamped to zero. For (L•N) < 0, result is clamped to zero. Ij Ie Ij and Ie are RGB color intensity values Ie has a direction L Note that Ij has no specific direction vector associated with it since it is the same over the entire hemisphere defined by N Ij  General Diffuse Example Ij = Ie Kd cos() or Ij = Ie Kd (L•N) cos() accounts for the change in projected surface area of incident light Ie and surface orientation toward/away from light L•N computes cos () function if L and N are normalized vectors Kd is RGB vector of “diffuse color” coefficients in range [0,1] Two lights (UL and LR) produce diffuse reflections on spheres Diffuse reflection on a sphere from one light diffuse reflection on a teapot How many lights? Combined Specular and Diffuse Reflection Real materials exhibit a mix of both diffuse and specular reflection characteristics The diffuse intensity is constant and a bulge or peak of specular intensity occurs near the R direction A camera “sees” the energy emitted in it’s direction (V or E) V or E direction points toward the viewer, eye, or camera N L R E Ie Examples of Combined Model The reflection distribution can be a sharp-peak or a broad-bump of reflected energy in the R direction, controlled by the specular-power “spec” The diffuse reflection produces smooth color variation over the model portion facing the light(s) (view-independent) The specular reflection produces a highlight that moves as the viewpoint (E) changes (view-dependent) Where is the sphere bottom? N L R E Ie Ambient Light Surfaces facing away from a light will be black No diffuse or specular reflection intensity To avoid this, create a special light that hits all surfaces A lumped omnidirectional source is called the ambient light Ambient light Ia is an fixed intensity vector and considered “normal” to all surfaces Ambient light produces an additional diffuse-like reflection called an ambient reflection Ka is specified for materials as the “ambient color” Use separate Ka for HW4 other systems may set Ka = Kd Only one ambient light is needed and allowed With ambient light Without ambient light Specular, Diffuse, and Ambient Reflection Components All 3 reflection behaviors create a complete shading model Specular reflection intensity specular component = Ie Ks (RE)spec Diffuse reflection intensity diffuse component = Ie Kd (NL) Ambient reflection intensity ambient component = Ia Ka E or V Complete Shading Equation Surface color seen by camera at a surface point is modeled by summing the light-surface interactions over all lights Color C = lights specular + diffuse + ambient components = (Ks [Ie (RE)s]) + (Kd [Ie (NL)]) + (Ka Ia) S is a scalar C, Ie, Ks, Kd, Ka, Ia – are all RGB color vectors ( [0, 1]) R = reflected ray direction vector (normalized) E = eye ray direction vector (normalized) N = surface normal vector (normalized) L = light ray direction vector (normalized) Specular Power Variations Parameter Example with varied Kd, Ks, and spec pwr Observations about Specular, Diffuse, and Ambient Reflection Components Absorption (or color) for each reflection component is modeled by Ks, Kd, Ka ---- each is a vector of fractional attenuations [0,1] For most real materials, these equations are only approximate Cos laws approximate the behavior of light with real materials K terms are often a function of incident/reflection angle and wavelength Surface appearance is set by specifying Kd, Ks, Ka and spec power s Kd, Ks, Ka  [0,1] for each rgb vector element Sharpness of specular highlight is controlled by specular power “s” “s” is often constrained to be a binary power for fast calculation (1, 2, 4, 8, 16, 32, … ) The surface reflection model applies to any geometry, but Normal vector at each point determines appearance Implementing the Shading Equation Color C = lights specular + diffuse + ambient components = (Ks [Ie (RE)s]) + (Kd [Ie (NL)]) + (Ka Ia) C, Ie, Ks, Kd, Ka, Ia – are all RGB color vectors ( [0, 1]) R = reflected ray direction vector (normalized) E = eye ray direction vector (normalized) N = surface normal vector (normalized) L = light ray direction vector (normalized) This is an approximate model of illumination of opaque surfaces But…, geometry is involved -- dot products, cosines Recall that the rasterizer operates on coordinates after perspective projection. Perspective does not preserve angles or lengths. Lighting calculations must be done in some space before the perspective projection. Model, world, or image space? 2 P 1 P ò W = w q w d x I E cos ) , ( q ) , ( w x I W N L diffuse Ie Ij r =

Leave a Reply

Your email address will not be published. Required fields are marked *