CS 551/651: Advanced Computer Graphics Advanced Ray Tracing Radiosity

advertisement
CS 551/651:
Advanced Computer Graphics
Advanced Ray Tracing
Radiosity
David Luebke
1
7/27/2016
Administrivia

My penance: Ray tracing homeworks very
slow to grade





Many people didn’t include READMEs
Many (most) people didn’t include
workspace/project files or Makefiles
Some people’s don’t work
Nobody’s works perfectly
Quiz 1: Tuesday, Feb 20
David Luebke
2
7/27/2016
Recap: Stochastic Sampling
Sampling theory tells us that with a regular
sampling grid, frequencies higher than the
Nyquist limit will alias
 Q: What about irregular sampling?
 A: High frequencies appear as noise, not
aliases
 This turns out to bother our visual system less!

David Luebke
3
7/27/2016
Recap: Stochastic Sampling

Poisson distribution:



Completely random
Add points at random until area is full.
Uniform distribution: some neighboring samples
close together, some distant
David Luebke
4
7/27/2016
Recap: Stochastic Sampling

Poisson disc distribution:



Poisson distribution, with minimum-distance
constraint between samples
Add points at random, removing again if they are
too close to any previous points
Jittered distribution



Start with regular grid of samples
Perturb each sample slightly in a random direction
More “clumpy” or granular in appearance
David Luebke
5
7/27/2016
Recap: Stochastic Sampling

Spectral characteristics of these distributions:



Poisson: completely uniform (white noise). High
and low frequencies equally present
Poisson disc: Pulse at origin (DC component of
image), surrounded by empty ring (no low
frequencies), surrounded by white noise
Jitter: Approximates Poisson disc spectrum, but
with a smaller empty disc.
David Luebke
6
7/27/2016
Recap: Nonuniform
Supersampling

To be correct, need to modify filtering step:
David Luebke
7
7/27/2016
Recap: Nonuniform
Supersampling

Approximate answer: weighted average filter
  I(i, j) h(x-i, y-j)
I’(x,y) =   h(x-i, y-j)
Correct answer: multistage filtering
 Real-world answer: ignore the problem

David Luebke
8
7/27/2016
Recap: Antialiasing and
Texture Mapping

Texture mapping is uniquely harder


Potential for infinite frequencies
Texture mapping is uniquely easier

Textures can be prefiltered
David Luebke
9
7/27/2016
Recap: Antialiasing and Texture
Mapping
Issue in prefiltering texture is how much
texture a pixel filter covers
 Simplest prefiltering scheme: MIP-mapping




Idea: approximate filter size, ignore filter shape
Create a pyramid of texture maps
Each level doubles filter size
David Luebke
10
7/27/2016
Recap: Mip-Mapping

Tri-linear mip-mapping



Pixel size  depth d
Linearly interpolate colors within 2 levels
closest to d
Linearly interpolate color between levels
according to d
David Luebke
11
7/27/2016
Distributed Ray Tracing

Distributed ray tracing is an elegant technique
that tackles many problems at once


Stochastic ray tracing: distribute rays
stochastically across pixel
Distributed ray tracing: distribute rays
stochastically across everything
David Luebke
12
7/27/2016
Distributed Ray Tracing

Distribute rays stochastically across:






Pixel for antialiasing
Light source for soft shadows
Reflection function for soft (glossy) reflections
Time for motion blur
Lens for depth of field
Cook: 16 rays suffice for all of these

I done told you wrong: 4x4, not 8x8
David Luebke
13
7/27/2016
Distributed Ray Tracing
Distributed ray tracing is basically a Monte
Carlo estimation technique
 Practical details:



Use lookup tables (LUTs) for distributing rays
across functions
See W&W Figure 10.14 p 263
David Luebke
14
7/27/2016
Backwards Ray Tracing
Traditional ray tracing traces rays from the
eye, through the pixel, off of objects, to the
light source
 Backwards ray tracing traces rays from the
light source, into the scene, into the eye
 Why might this be better?

David Luebke
15
7/27/2016
Backwards Ray Tracing

Backwards ray tracing can capture:



Indirect illumination
Color bleeding
Caustics
 Remember
what a caustic is?
 Give some examples
 Remember where caustics get the name?
David Luebke
16
7/27/2016
Backwards Ray Tracing

Usually implies two passes:


Rays are cast from light into scene
Rays are cast from the eye into scene, picking up
illumination showered on the scene from the first
pass
David Luebke
17
7/27/2016
Backwards Ray Tracing

Q: How might these two passes “meet in the
middle?”
David Luebke
18
7/27/2016
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
19
7/27/2016
Backwards Ray Tracing

Watt & Watt, Plate 34



Illustrates Arvo’s method of backwards ray tracing
using illumination maps
Illustrates a scene with caustics
Related idea: photon maps
David Luebke
20
7/27/2016
Advanced Ray Tracing Wrapup
Backwards ray tracing accounts for indirect
illumination by considering more general paths
from light to eye
 Distributed ray tracing uses a Monte Carlo
sampling approach to solve many ray-tracing
aliasing problems

David Luebke
21
7/27/2016
Next Up: Radiosity

Ray tracing:



Models specular reflection easily
Diffuse lighting is more difficult
Radiosity methods explicitly model light as an
energy-transfer problem


Models diffuse interreflection easily
Shiny, specular surfaces more difficult
David Luebke
22
7/27/2016
Radiosity Introduction

First lighting model: Phong



Still used in interactive graphics
Major shortcoming: local illumination!
After Phong, two major approaches:


Ray tracing
Radiosity
David Luebke
23
7/27/2016
Radiosity Introduction

Ray tracing: ad hoc approach to simulating
optics



Deals well with specular reflection
Trouble with diffuse illumination
Radiosity: theoretically rigorous simulation of
light transfer


Very realistic images
But makes simplifying assumption: only diffuse
interaction!
David Luebke
24
7/27/2016
Radiosity Introduction

Ray-tracing:



Computes a view-dependent solution
End result: a picture
Radiosity:


Models only diffuse interaction, so can compute a
view-independent solution
End result: a 3-D model
David Luebke
25
7/27/2016
Radiosity
Basic idea: represent surfaces in environment
as many discrete patches
 A patch, or element, is a polygon over which
light intensity is constant

David Luebke
26
7/27/2016
Radiosity
Model light transfer between patches as a
system of linear equations
 Solving this system gives the intensity at each
patch
 Solve for R, G, B intensities and get color at
each patch
 Render patches as colored polygons in
OpenGL. Voila!

David Luebke
27
7/27/2016
Fundamentals
Theoretical foundation: heat transfer
 Need system of equations that describes
surface interreflections
 Simplifying assumptions:



Environment is closed
All surfaces are Lambertian reflectors
David Luebke
28
7/27/2016
Radiosity
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




Notice: previous methods distinguish light sources
from surfaces
In radiosity all surfaces can emit light
Thus: all emitters inherently have area
David Luebke
29
7/27/2016
Radiosity

Break environment up into a finite number n of
discrete patches


Patches are opaque Lambertian surfaces of finite
size
Patches emit and reflect light uniformly over their
entire surface
Q: What’s wrong with this model?
 Q: What can we do about it?

David Luebke
30
7/27/2016
Radiosity

Then 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
31
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
David Luebke
32
7/27/2016
Form Factors

Some examples…
Form factor:
nearly 100%
David Luebke
33
7/27/2016
Form Factors

Some examples…
Form factor:
roughly 50%
David Luebke
34
7/27/2016
Form Factors

Some examples…
Form factor:
roughly 10%
David Luebke
35
7/27/2016
Form Factors

Some examples…
Form factor:
roughly 5%
David Luebke
36
7/27/2016
Form Factors

Some examples…
Form factor:
roughly 30%
David Luebke
37
7/27/2016
Form Factors

Some examples…
Form factor:
roughly 2%
David Luebke
38
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
39
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?
40
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!
41
7/27/2016
Radiosity

Now “just” need to solve the matrix!


W&W: matrix is “diagonally dominant”
Thus Guass-Siedel must converge
End result: radiosities for all patches
 Solve RGB radiosities separately, color each
patch, and render!
 Caveat: actually, color vertices, not patches
(see F&vD p 795)

David Luebke
42
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
43
7/27/2016
Radiosity

Where we go from here:



Evaluating form factors
Progressive radiosity: viewing an approximate
solution early
Hierarchical radiosity: increasing patch resolution
on an as-needed basis
David Luebke
44
7/27/2016
The End
David Luebke
45
7/27/2016
Download