CS 445 / 645 Introduction to Computer Graphics Lecture 17 Radiosity Assignment Four Write a ray tracer You’ll have complete control • Input file format • User.

Download Report

Transcript CS 445 / 645 Introduction to Computer Graphics Lecture 17 Radiosity Assignment Four Write a ray tracer You’ll have complete control • Input file format • User.

CS 445 / 645
Introduction to Computer Graphics
Lecture 17
Radiosity
Assignment Four
Write a ray tracer
You’ll have complete control
• Input file format
• User interface
• Data structures
• Form a two-person group
From Fall ‘03
Shane Liesegang
William Kammersell
Adam Jones, Richard Sun
Raytracing vs. Radiosity
Both accomplish global illumination
• Raytracing
– Follow rays of energy as they bounce through a scene
 Which rays?
Pick some. Randomness helps.
Monte Carlo. Still a research topic.
 How many rays?
Derek Juba and Matt Helton
UVa Intro to Gaphics, Fall 2003
Depends on the scene. Still a
topic of research debate.
Courtyard
House with Curved
Elements
Complex
Indirect
Illumination
Mies van der Rohe
Modeling: Stephen Duck; Rendering: Henrik Wann Jensen
Raytracing vs. Radiosity
Both accomplish global illumination
• Radiosity
– Compute energy transfer between finite-sized
patches of surfaces in the scene
 Which patches?
Must subdivide the scene
somehow
 How does energy transfer between patches?
Approximating models
Still an area of research
Which is better?
Herik Wann Jensen
Raytraced
Radiosity
• Radiosity captures the sum of light transfer well
– But it models all surfaces as diffuse reflectors
– Can’t model specular reflections or refraction
 Images are viewpoint independent
• Raytracing captures the complex behavior of light rays as they reflect and
refract
– Works best with specular surfaces. Why?
 Diffuse surface converts light ray into many. Ray tracing follows
one ray and does not capture the full effect of the diffusion.
 Must use ambient term to replace absent diffusion
Lighting Example: Cornell Box
Surface Color
Lighting Example: Diffuse Reflection
Surface Color
Diffuse Shading
Lighting Example: Shadows
No Shadows
Shadows
Lighting Example: Soft Shadows
Hard Shadows
Point Light Source
Soft Shadows
Area Light Source
Radiosity: Cornell Experment
Measured
Simulated
Program of Computer Graphics
Cornell University
Radiosity: Cornell Experiment
Measured
Simulated
Difference
Very Early Radiosity
Parry Moon and Domina Spencer Lighting Design (1948 - MIT)
Very Early Radiosity
Goral et al. 1984.
• Note the color bleeding
Early Radiosity
Shenchang Eric Chang et al., Cornell 1988
The ‘Rendering Equation’
Jim Kajiya (Current head of Microsoft Research) developed this in
1986


I  x, x'  g  x, x'e  x, x'   r  x, x' , x' 'I  x' , x' 'dx' '
S


I(x, x’) is the total intensity from point x’ to x
g(x, x’) = 0 when x/x’ are occluded and 1/d2 otherwise (d = distance
between x and x’)
e(x, x’) is the intensity emitted by x’ to x
r(x, x’,x’’) is the intensity of light reflected from x’’ to x through x’
S is all points on all surfaces
Radiosity
All surfaces are assumed perfectly diffuse
• What does that mean about property of lighting in scene?
– Light is reflected equally in all directions
• Same lighting independent of viewing angle / location
– Only a subset of the Rendering Equation
Diffuse-diffuse surface lighting effects possible
Radiosity Terms
Radiant power [flux] (F)
•
Rate at which light energy is transmitted (in watts = joules/sec).
Radiant Intensity (I)
•
Power radiated onto a unit solid angle in direction
(in watts/steradian)
Radiance (L)
•
Intensity per unit projected surface area
(in watts/m2steradian)
Irradiance (E)
•
Incident flux density on a locally planar area
(in watts/m2 )
Radiosity (B)
•
Exitant flux density from a locally planar area (in watts/ m2 )
Basic elements of radiosity
Assume surface is Lambertian
• dB is the visible radiant flux emanating
from the surface point in the direction
given by the angles q and f within a
differential solid angle dw per unit time,
per unit of surface area
Basic elements of radiosity
The intensity, I
• The diffuse radiation in direction (q, f)
– Radiant energy
 per unit time
 per projected area
 per unit solid angle
Basis elements of radiosity
We have the intensity of radiance in a given
direction with a given solid angle…
How will we compute the radiation
for all directions?
Radiosity equation
Bk – total rate of radiant energy leaving surface k
per unit area
Hk – sum of the radiant energy contributions from
all surfaces in the rendered volume arriving
at surface k per unit time per unit area
Form Factor
Form factor, Fjk
The fractional amount of radiant energy from
surface j that reaches surface k
We’ll discuss different form factor approximations later.
Radiosity equation
Permit surface k to emit light:
Ek = 0 if surface k is not a light
Ek = rate of energy emitted by surface k per unit
area (watts/m2)
Radiosity equation
Permit surface k to have variable reflectance
rk is the reflectivity factor for surface k (percent of
incident light that is reflected in all directions)
Radiosity equation
For a single surface, k
• Note: Fkk = 0 because planar and convex surfaces cannot
“see” themselves
How will we compute this for all surfaces?
Radiosity equation
Obtaining illumination effects for all surfaces in
the rendered volume
• Find Bk for all surfaces, k
• What do we know ahead of time?
– Ek, rk, Fjk
Radiosity equation
Consider three surfaces
Three equations and three unknowns!
Consider three surfaces
Move
terms
around
Invert and solve for B vector
Extending to more surfaces
Remember, Fk,k = 0
Solving for all Patches
Difficult to perform Gaussian Illumination and
solve for b (size of F is large but sparse – why?)
Instead, iterate:
bk+1 = e – Fbk
• Multiplication of sparse matrix is O(n), not O(n2)
• Stop when bk+1 = bk
Back to the Form Factors
Fij
= energy transfer from surface i to j
= percent of energy emanating from i that
is incident on j
This is a good image
from Foley et al. Note
theta in the image
corresponds to phi in
our Hearn and Baker.
Form factors
Consider the differential units
• For some small area of surface i and some small area of j
Form factors
r
Remember, theta from our example = phi from the images and
examples of Hearn and Baker
dA
Form factors
Form factors
Final answer
Visibility factor
Normalize for the size of
patch A_i
Form Factor – Another image
Spherical projections to model form factor
• project polygon Aj on unit hemisphere centered at (and tangent to) Ai
– Contributes cosqj / r2
• Project this projection to
base of hemisphere
– Contributes cosqi
• Divide this area by area
of circle base
– Contributes p12
dFdi ,dj 
cosq i cosq j
pr
2
H ij dAj
Form Factor – Another Model
Hemicube allows faster computations
• Analytic solution of hemisphere is expensive
• Use rectangular approximation, hemicube
• cosine terms for top and sides
are simplified
• Dimension of 50 – 200 squares
is good
BRDFs
Bidirectional Reflection Distribution Function
• Models how much light is reflected in direction w0 from
direction wi
• These functions can be predefined for a surface to facilitate
the computation of the form factors
– How much light reflects in some given direction?
– Take light coming from all incoming directions, multiply it
by the BRDF, multiply by cos(q)
Radiosity
Radiosity is expensive to compute
• Get your PhD by improving it
Some parts of illuminated world can change
• Emitted light
• Viewpoint
Other things cannot
• Light angles
• Object positions and occlusions
• Computing form factors is expensive
Specular reflection information is not modeled
View-dependent vs
View-independent
Ray-tracing models specular reflection well, but
diffuse reflection is approximated
Radiosity models diffuse reflection accurately, but
specular reflection is
ignored
Advanced algorithms
combine the two
Aliasing in radiosity
Non-axis aligned meshes
Doing a better job with discontinuities
Engine Room
Architectural
design