lecture09.ppt

Download Report

Transcript lecture09.ppt

CS 551/651:
Advanced Computer Graphics
Advanced Ray Tracing
Radiosity
David Luebke
1
7/27/2016
Administrivia

Quiz 1: Tuesday, Feb 20


Yes, I’ll have your homework graded by then
(somehow)
Normal written exam (oral later)
David Luebke
2
7/27/2016
Recap: Distributed Ray Tracing

Distributed ray tracing: an elegant stochastic
approach that distributes rays across:






Pixel for antialiasing
Light source for soft shadows
Reflection function for soft (glossy) reflections
Time for motion blur
Lens elements for depth of field
Cook: 16 rays suffice for all of these
David Luebke
3
7/27/2016
Recap: Backwards Ray Tracing

Two-pass algorithm:



Rays are cast from light into scene
Rays are cast from the eye into scene, picking up
illumination showered on the scene in the first pass
Backwards ray tracing can capture:



Indirect illumination
Color bleeding
Caustics
David Luebke
4
7/27/2016
Recap: Backwards Ray Tracing

Arvo: illumination maps tile surfaces with
regular grids, like texture maps


Shoot rays outward from lights
Every ray hit deposits some of its energy into
surface’s illumination map
 Ignore
first generation hits that directly illuminate
surface (Why?)

Eye rays look up indirect illumination using
bilinear interpolation
David Luebke
5
7/27/2016
Recap: Radiosity

Ray tracing:




Models specular reflection easily
Diffuse lighting is more difficult
View-dependent, generates a picture
Radiosity methods explicitly model light as an
energy-transfer problem



Models diffuse interreflection easily
But only diffuse; no shiny (specular) surfaces
View-independent, generates a 3-D model
David Luebke
6
7/27/2016
Recap: Radiosity

Basic idea: represent surfaces in environment
as many discrete patches





A patch, or element, is a polygon over which light
intensity is constant
Model light transfer between patches as a system
of linear equations
Solve this system for the intensity at each patch
Solve for R,G,B intensities; get color at each patch
Render patches as colored polygons in OpenGL
David Luebke
7
7/27/2016
Recap: Fundamentals

Definition:

The radiosity of a surface is the rate at which
energy leaves the surface
 Radiosity
= rate at which the surface emits energy + rate
at which the surface reflects energy

Simplifying assumptions



Environment is closed
All surfaces have Lambertian reflectance
Surface patches emit and reflect light uniformly
over their entire surface
David Luebke
8
7/27/2016
Radiosity

For each surface i:
Bi = Ei + i  Bj Fji (Aj / Ai)
where
Bi, Bj= radiosity of patch i, j
Ai, Aj= area of patch i, j
Ei = energy/area/time emitted by i
i = reflectivity of patch i
Fji = Form factor from j to i
David Luebke
9
7/27/2016
Form Factors

Form factor: fraction of energy leaving the
entirety of patch i that arrives at patch j,
accounting for:




The shape of both patches
The relative orientation of both patches
Occlusion by other patches
We’ll return later to the calculation of form
factors
David Luebke
10
7/27/2016
Form Factors

Some examples…
Form factor:
nearly 100%
David Luebke
11
7/27/2016
Form Factors

Some examples…
Form factor:
roughly 50%
David Luebke
12
7/27/2016
Form Factors

Some examples…
Form factor:
roughly 10%
David Luebke
13
7/27/2016
Form Factors

Some examples…
Form factor:
roughly 5%
David Luebke
14
7/27/2016
Form Factors

Some examples…
Form factor:
roughly 30%
David Luebke
15
7/27/2016
Form Factors

Some examples…
Form factor:
roughly 2%
David Luebke
16
7/27/2016
Form Factors

In diffuse environments, form factors
obey a simple reciprocity relationship:
Ai Fij = Ai Fji

Which simplifies our equation:
Bi = Ei + i

Rearranging to:
Bi - i
David Luebke
 Bj Fij
 Bj Fij = Ei
17
7/27/2016
Form Factors

So…light exchange between all patches
becomes a matrix:
1  1F11  1F12
 F
1


F
2
21
2
22

 


  n Fn1  n Fn 2

David Luebke
 1F1n   B1   E1 





 2 F2 n   B2   E2 

     


   
 1  n Fnn   Bn   En 


What do the various terms mean?
18
7/27/2016
Form Factors
1 - 1F11
- 2F21
.
.
.
- pnFn1




David Luebke
- 1F12
1 - 2F22
.
.
.
- nFn2
… - 1F1n
… - 2F2n
…
.
…
.
…
.
… 1 - nFnn
B1
B2
.
.
.
Bn
E1
E2
.
.
.
En
Note: Ei values zero except at emitters
Note: Fii is zero for convex or planar patches
Note: sum of form factors in any row = 1 (Why?)
Note: n equations, n unknowns!
19
7/27/2016
Radiosity

Now “just” need to solve the matrix!


W&W: matrix is “diagonally dominant”
Thus Guass-Siedel must converge (what’s that?)
End result: radiosities for all patches
 Solve RGB radiosities separately, color each
patch, and render!
 Caveat: for rendering, we actually color
vertices, not patches (see F&vD p 795)

David Luebke
20
7/27/2016
Radiosity
Q: How many form factors must be computed?
 A: O(n2)
 Q: What primarily limits the accuracy of the
solution?
 A: The number of patches

David Luebke
21
7/27/2016
Roadmap

So, we know the basic radiosity algorithm



Represent light transfer as a matrix
Solve the matrix to get radiosity (=color) per patch
Next topics:



Evaluating form factors
Progressive radiosity: viewing an approximate
solution early
Hierarchical radiosity: increasing patch resolution
on an as-needed basis
David Luebke
22
7/27/2016
Form Factors

Calculating form factors is hard

Analytic form factor between two polygons in
general case: open problem till last few years
Q: So how might we go about it?
 Hint: Clearly form factors are related to
visibility: how much of patch j can patch i
“see”?

David Luebke
23
7/27/2016
Form Factors: Hemicube

Hemicube algorithm: Think Z-buffer





Render the model onto a hemicube as seen from
the center of patch i
Store item IDs instead of color
Use Z-buffer to resolve visibility
See W&W p 278
Q: Why hemicube, not hemisphere?
David Luebke
24
7/27/2016
Form Factors: Hemicubes

Advantages of hemicubes


Solves shape, size, orientation, and occlusion
problems in one framework
Can use hardware Z-buffers to speed up form
factor determination (How?)
David Luebke
25
7/27/2016
Form Factors: Hemicubes

Q: What are some disadvantages of
hemicubes?

Aliasing! Low resolution buffer can’t capture
actual polygon contributions very exactly
 Causes

“banding” near lights (plate 41)
Actual form factor is over area of patch; hemicube
samples visibility at only center point on patch
(So?)
David Luebke
26
7/27/2016
Form Factors: Ray Casting

Idea: shoot rays from center of patch in
hemispherical pattern
David Luebke
27
7/27/2016
Form Factors: Ray Casting

Advantages:

Hemisphere better approximation than hemicube
 More


even sampling reduces aliasing
Don’t need to keep item buffer
Slightly simpler to calculate coverage
David Luebke
28
7/27/2016
Form Factors: Ray Casting

Disadvantages:



Regular sampling still invites aliasing
Visibility at patch center still isn’t quite the same
as form factor
Ray tracing is generally slower than
Z-buffer-like hemicube algorithms
 Depends
on scene, though
 Q: What kind of scene might ray tracing actually be
faster on?
David Luebke
29
7/27/2016
Form Factors

Source-to-vertex form factors

Calculating form factors at the patch vertices
helps address some problems:
for every patch vertex
for every source patch
sample source evenly with rays
visibility = % rays that hit

David Luebke
Q: What are the problems with this
approach?
30
7/27/2016
Form Factors

Summary of form factor computation

Analytical:
 Expensive

or impossible (in general case)
Hemicube
 Fast,
especially using graphics hardware
 Not very accurate; aliasing problems

Ray casting
 Conceptually
cleaner than hemicube
 Usually slower; aliasing still possible
David Luebke
31
7/27/2016
Substructuring
More patches  better results
 Problem: # form factors grows quadratically
with # patches
 Substructuring: adaptively subdivide patches
into elements where high radiosity gradient is
found

David Luebke
32
7/27/2016
Substructuring

Elements are second-class patches:


When a patch is subdivided, form factors are
computed from the elements to other patches
But form factors from the other patches to the
elements are not computed
 However,
the form factors from other patches to the
subdivided patch are updated using more accurate areaweighted average of elements
David Luebke
33
7/27/2016
Substructuring

Elements vs. patches, cont.



Elements “gather” radiosity from other patches
But those other patches only gather radiosity from
the “parent” patch, not the individual elements
So an element’s contribution to other patches is
approximated coarsely by it’s patch’s radiosity
David Luebke
34
7/27/2016
Substructuring

Bottom line:


Substructuring allows subpatch radiosities to be
computed without changing the size of the formfactor matrix
Show examples:
 W&W

plate 38, F&vD plate III.21
Note: texts aren’t clear about adaptive subdivision
vs substructuring
David Luebke
35
7/27/2016
Progressive Radiosity
Good news: iterative solver of radiosity matrix
will converge
 Bad news: can take a long time
 Progressive radiosity: reorder computation to
allow viewing of partial results

David Luebke
36
7/27/2016
Progressive Radiosity

Radiosity as described uses Gauss-Seidel
iterative solver


Must do an entire iteration to get an estimate of
patch radiosities
Must precompute and store all O(n2) form factors
David Luebke
37
7/27/2016
Progressive Radiosity
1 - 1F11
- 2F21
.
.
.
- pnFn1


David Luebke
- 1F12
1 - 2F22
.
.
.
- nFn2
… - 1F1n
… - 2F2n
…
.
…
.
…
.
… 1 - nFnn
B1
B2
.
.
.
Bn
E1
E2
.
.
.
En
Evaluating row i estimates radiosity of patch i based on
all other patches
We say the patch gathers light from the environment
38
7/27/2016
Progressive Radiosity

Progressive radiosity shoots light from a patch
into the environment:
Bj due to Bi = j Bj Fji
Bi due to Bj = i Bj Fij

j
j
rather than
Given an estimate of Bi, evaluating this
equation estimates patch i’s contribution to the
rest of the scene
David Luebke
39
7/27/2016
Progressive Radiosity

A problem: evaluating the equation
Bj due to Bi = j Bj Fji j
requires knowing Fji for each patch j
 Determining these values requires a hemicube
computation per patch
 Use reciprocity relationship to get
Bj due to Bi = j Bj Fij (Ai/Aj)
David Luebke
40
j
7/27/2016
Progressive Radiosity

Now evaluation requires only a single
hemicube about patch i



Compute, use, and discard form factors
Drastically reduces total storage!
Reorder radiosity computation:

Pick patch w/ highest estimated radiosity
 Shoot
to all other patches
 Update their estimates

David Luebke
Pick new “brightest” patch and repeat
41
7/27/2016
Progressive Radiosity
We can look at the scene after every
iteration through this loop
 Q: How will it look after 1 loop?
 Q: 2 loops?
 Q: If m = # of light sources, how will it
look after m loops? After 2m loops?

David Luebke
42
7/27/2016
Progressive Radiosity

Subtleties:

Pick patch with most energy to shoot
 Energy


= radiosity * area = Bj Ai
A patch may be selected to shoot again after new
light has been shot to it
So don’t shoot Bj , shoot Bj, the amount of
radiosity patch i has received since it was last shot
David Luebke
43
7/27/2016
The End
David Luebke
44
7/27/2016