David Luebke 1 10/12/2015 CS 551/651: Advanced Computer Graphics Advanced Ray Tracing Radiosity.
-
Upload
asher-rodgers -
Category
Documents
-
view
222 -
download
1
Transcript of David Luebke 1 10/12/2015 CS 551/651: Advanced Computer Graphics Advanced Ray Tracing Radiosity.
David Luebke 1 04/19/23
CS 551/651: Advanced Computer Graphics
Advanced Ray Tracing
Radiosity
David Luebke 2 04/19/23
Administrivia
Quiz 1: Tuesday, Feb 20 Yes, I’ll have your homework graded by then
(somehow) Normal written exam (oral later)
David Luebke 3 04/19/23
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 4 04/19/23
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 5 04/19/23
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 6 04/19/23
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 7 04/19/23
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 8 04/19/23
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 9 04/19/23
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 10 04/19/23
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 11 04/19/23
Form Factors
Some examples…
Form factor: nearly 100%
David Luebke 12 04/19/23
Form Factors
Some examples…
Form factor: roughly 50%
David Luebke 13 04/19/23
Form Factors
Some examples…
Form factor: roughly 10%
David Luebke 14 04/19/23
Form Factors
Some examples…
Form factor: roughly 5%
David Luebke 15 04/19/23
Form Factors
Some examples…
Form factor: roughly 30%
David Luebke 16 04/19/23
Form Factors
Some examples…
Form factor: roughly 2%
David Luebke 17 04/19/23
Form Factors
In diffuse environments, form factors obey a simple reciprocity relationship:
Ai Fij = Ai Fji
Which simplifies our equation:
Bi = Ei + i Bj Fij
Rearranging to:
Bi - i Bj Fij = Ei
David Luebke 18 04/19/23
Form Factors
So…light exchange between all patches becomes a matrix:
What do the various terms mean?
nnnnnnnnn
n
n
E
E
E
B
B
B
FFF
FFF
FFF
2
1
2
1
21
22222212
11121111
1
1
1
David Luebke 19 04/19/23
Form Factors
1 - 1F11 - 1F12 … - 1F1n B1 E1
- 2F21 1 - 2F22 … - 2F2n B2 E2
. . … . . .
. . … . . .
. . … . . .
- pnFn1 - nFn2 … 1 - nFnn Bn 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!
David Luebke 20 04/19/23
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 21 04/19/23
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 22 04/19/23
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 23 04/19/23
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 24 04/19/23
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 25 04/19/23
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 26 04/19/23
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 27 04/19/23
Form Factors: Ray Casting
Idea: shoot rays from center of patch in hemispherical pattern
David Luebke 28 04/19/23
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 29 04/19/23
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 30 04/19/23
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 Q: What are the problems with this
approach?
David Luebke 31 04/19/23
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 32 04/19/23
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 33 04/19/23
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 area-weighted average of elements
David Luebke 34 04/19/23
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 35 04/19/23
Substructuring
Bottom line: Substructuring allows subpatch radiosities to be
computed without changing the size of the form-factor matrix
Show examples: W&W plate 38, F&vD plate III.21
Note: texts aren’t clear about adaptive subdivision vs substructuring
David Luebke 36 04/19/23
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 37 04/19/23
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 38 04/19/23
Progressive Radiosity
1 - 1F11 - 1F12 … - 1F1n B1 E1
- 2F21 1 - 2F22 … - 2F2n B2 E2
. . … . . .
. . … . . .
. . … . . .
- pnFn1 - nFn2 … 1 - nFnn Bn En
Evaluating row i estimates radiosity of patch i based on all other patches
We say the patch gathers light from the environment
David Luebke 39 04/19/23
Progressive Radiosity
Progressive radiosity shoots light from a patch into the environment:
Bj due to Bi = j Bj Fji j rather than
Bi due to Bj = i Bj Fij j Given an estimate of Bi, evaluating this
equation estimates patch i’s contribution to the rest of the scene
David Luebke 40 04/19/23
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) j
David Luebke 41 04/19/23
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
Pick new “brightest” patch and repeat
David Luebke 42 04/19/23
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 43 04/19/23
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 44 04/19/23
The End