other rendering techniquescse872/rendering.pdfcse 872 fall 2011 5 raytracing •arthur appel in 1968...
TRANSCRIPT
CSE 872 Fall 20111
Other Rendering Techniques
CSE 872 Fall 20112
Intro
You have seen•Scanline converter (+z-buffer)•Painter’s algorithm•Radiosity
CSE 872 Fall 20113
IntroSome more…•Raytracing•Light maps•Photon-map•Reyes•Shadow maps•Sahdow volumes•PRT•BSSRF
CSE 872 Fall 20114
Raytracing
ObjectCoordinates
Modelv
iew
Matrix
Inters
ection
Data Stru
cture
Eye coo
rdinat
es
Raytracing then utilizes thisdata structure to build the image.
CSE 872 Fall 20115
Raytracing•Arthur Appel in 1968 Ray casting•Turner Whitted
“An improved illumination model for shaded display” June, 1980 Communications of the ACM.
more about illumination model
CSE 872 Fall 20116
That Pinhole Camera Model
After eyespace transformationProjection Plane at z=-d
CSE 872 Fall 20117
Raytracingcenter of projection through the center of a pixel and off into space…
What does it hit first?If it hits an object, compute the color for that point on the objectThat’s the pixel color
CSE 872 Fall 20118
RaysA Ray is a vector and a point
Point – The starting point of the rayVector – The ray directionThis describes an infinite line starting at the point and going in the ray direction
Ray t valuesA distance along the ray t=1.5
CSE 872 Fall 20119
View Plane:Pixel Grid
0
0 1 2 3 4
1
23
CSE 872 Fall 201110
Visible Surface Raytracing// width – Screen width, height – Screen height// fov – Field of view in degrees, aspect – Aspect ratiodouble ey = tan(fov / 2. * DEGTORAD); double ehit=2 * ey;double ex = ey * aspect; double ewid = 2 * ex;
for(int r=0; r<height; r++) for(int c=0; c<width; c++){
ray.start.Set(0,0,0);ray.dir.Set(-ex + ewid * (c + 0.5) / width,
-ey + ehit * (r + 0.5) / height,-1.);
ray.dir.Normalize();
// Compute color in ray direction// Save color as image pixel
}
CSE 872 Fall 201111
what will we hit?Ray intersection tests
Reduces to solving for tx = xs + t xd
y = ys + t yd
z = zs + t zd
Easiest is the sphere(x-x0)2+(y-y0)2+(z-z0)2=r2
Substitute ray equation in and solve for t
CSE 872 Fall 201112
Intersection w/ a sphere
220
20
20
000
222
2
2,1
)()()(
))()()((2
24
rzzyyxxC
zzzyyyxxxBzyxA
AACBBt
sss
sdsdsd
ddd
−−+−+−=
−+−+−=++=
−±−=
Questions: Why two t values?How do we tell if there is an intersection?
CSE 872 Fall 201113
Intersections w/ a plane
Plane equationAx+By+Cz+D=0(A,B,C) is the plane normalWe can compute the normal and, given a single point, compute D
ddd
sss
CzByAxDCzByAxt
+++++
=
Questions: Can t be negative? Zero?Why is this “more difficult” than a sphere?
CSE 872 Fall 201114
Polygon IntersectionGiven a plane intersection, the question is:
Is this point inside the polygon?
CSE 872 Fall 201115
Reduce to 2DProject the polygon for the maximum area
What is the largest component of the normal?If x: Use a Y/Z projectionIf y: Use an X/Z projectionIf z: Use an X/Y projectionWhy?
CSE 872 Fall 201116
Why “impractical”?
Suppose you do a ray for every pixel and test against very polygon:
O(WHP)Then if we allow recursion…
CSE 872 Fall 201117
Faster Intersection Tests
Grouping objects and using bounding volumes
Bounding boxes are easier to test for intersections.Your chair object could have a box around each polygon and a box around the entire object.We can create hierarchical levels of bounding boxes pretty easily (cluster tree)Spheres are a common bounding volume
CSE 872 Fall 201118
Bounding box test
Assumes: Upright boxSometimes called “generalized box”
Consider box to have 6 planesPlanes are orthogonal to some axisBox with range: (0.5, 0.7, -1) to (1.3, 2.2, -4)Ray: R((0,0,0),(1, 1, -1)) What is “t” for intersections with box planes orthogonal to the X axis?
CSE 872 Fall 201119
Ray Walking Algorithmssubdivide the space into boxestrace the ray one box after another
CSE 872 Fall 201120
Ray Walking Algorithms
Not the same as line drawing:
= line draw= extras for ray
walking
CSE 872 Fall 201121
Spatial subdivisionsUniform divisions
All boxes are equal sizedAdvantages? Disadvantages?
Non-uniform divisionsHow? Why?
CSE 872 Fall 201122
Octtree-based
CSE 872 Fall 201123
Speed-upItem buffer
A z-buffer which holds pointers to objects rather than colorsHow can this speed up ray tracing?
Also called: First-hit speedup
CSE 872 Fall 201124
color?Intersection gives a point on a polygon
Apply the color modelHow do we get
View direction?Light direction?Normal?
CSE 872 Fall 201125
How do we do?Shadows?Reflections?
CSE 872 Fall 201126
Terms to knowShadow feeler
Casting a ray in the direction of the lightIf intersection is less than distance to the light, light is shadowed
Self shadowingRoundoff errors can make us intersect ourselves
CSE 872 Fall 201127
RecursionReflections (THE point of
raytracing)Simply compute the color in the reflection direction
What does this do to the running time?
Was O(WHP)
CSE 872 Fall 201128
Adaptive Depth ControlHow deep do you recurse?
A room with mirrors?A room with only specular reflection?
Keep track of how much a ray will contribute to the final color
Falls below some threshold, don’t recurse anymore…
CSE 872 Fall 201129
How do we do?Shadows?Penumbra?Depth of field?Motion blur?Antialiasing?
CSE 872 Fall 201130
Stochastic Ray TracingProblem with ray tracing:
Point sampling
We can introduce randomness all over the place
Jitter for antialiasingLight area for penumbraDepth of field and motion blur
[Jensen07]
CSE 872 Fall 201131
Minimum distance Poisson distribution
Better matches distribution in the eye
AlgorithmGenerate a random pointIf less than specified distance to nearest point, discard, otherwise keep
CSE 872 Fall 201132
Distribution Comparisons
Poisson Uniform
CSE 872 Fall 201133
Path Tracing1) Sample each pixel with N rays2) At each intersection, trace only one ray
proportion of rays in each category should match the actual (surface) distribution
Ray Tracing Path Tracing
Reduces the amount of work deeper in the ray tree
CSE 872 Fall 201134
Adaptive samplingDetermine if number of samples is enough
If not, increase the number
Works for uniform and stochastic sampling
CSE 872 Fall 201135
Finite AperturePerturb the raysOr jitter eye position
Depth of Field
[Jensen07]
CSE 872 Fall 201136
Motion Blur
[Jensen07]
Finite shutter opening timePerturb the rays in time
CSE 872 Fall 201137
Ray tracing from the light sources
In regular ray tracing we don’t seeLighting reflected through mirrorsSurfaces lit by reflection from other surfaces
Large set of rays from each lightComputes light that hits surfacesGeneral solution for diffuse reflection?Still requires tracing from the eye as pass 2
CSE 872 Fall 201138
Lightmap
•Precomputed lighting•Implement by multitexture•Why?
Texture can be re-usedLighting unique but low-res
[Cham
bers01]
CSE 872 Fall 201139
Photon map
•Photon by light-based raytracing•Separating GI from rendering•Stored in kd-trees•Good for
Caustics, subsurface scattering,…
CSE 872 Fall 201140
Photon path
Start from light sourcesIntensity -> photon
[Jensen]
CSE 872 Fall 201141
Final Gathering
•Radiance Computation•Distributed ray tracing
[Jensen]
CSE 872 Fall 201142
Another example
[Jensen00]
CSE 872 Fall 201143
Irradiance Caching•Similar Idea to lightmap
Irradiance has lower frequency (than radiance)
[Ward]
CSE 872 Fall 201144
Reyes RenderingDeveloped by LucasfilmIn use by Pixar (Renderman)Now combined with ray-tracing on demand
One tile at a timeSubdivide geometry to pixel size
CSE 872 Fall 201145
Design GoalsNatural Coordinates
Do calculations in coordinate system most natural for it.
Support for vectorization,parallelism,etc.All objects work with common
representationsMicropolygons
LocalityGeometric and Texture locality
CSE 872 Fall 201146
Design Goals (2)Linear in model sizeLarge models (larger than memory)Textures, textures, textures
Complex shadingBump and displacement maps
CSE 872 Fall 201147
Reyes Algorithm
read model
dice
shade
visibility
picture
texture
sample
CSE 872 Fall 201148
Micropolygons
CSE 872 Fall 201149
Sampling
CSE 872 Fall 201150
Shadow Maps
Render a depth image from the light position
For each pixel in final image:1) Transform into light space2) In shadow iff zinLightSpace > zshadowMap
Shadow map =
CSE 872 Fall 201151
Shadow Maps
CSE 872 Fall 201152
Deep Shadow Maps
3D texture where each point is how much illumination we receive
CSE 872 Fall 201153
Shadow VolumesPolygons cast polyhedra of shadow volumes
Intersect polyhedra and object space
CSE 872 Fall 201154
Real-time Rendering
TransportTransportComplexityComplexity
LightingLighting
simplesimple shadowsshadows
pointpointlightslights
full full envenv..mapmap
interinter--reflectionsreflections
singlesingleareaarealightlight
[Moeller02][Moeller02]
[Blinn76][Blinn76]
[Heidrich00][Heidrich00]
[Crow77][Crow77]
[Ashikhmin02][Ashikhmin02]
PrecomputedPrecomputedRadiance Radiance TransferTransfer
[Sloan02][Ng03][Zhou05][Ren06][Sun07]
CSE 872 Fall 201155
Precomputed Radiance Transfer
( )V sr
( ) ( )i iL s l B s=∑r r%
( )( ) ( ) ( ) ( , ) ( )i i NR v l B s V s f s v H s d s= ∑∫r r r r r r r%
( ) ( ) ( ) ( , ) ( )i i NR v l B s V s f s v H s d s=∑ ∫r r r r r r r%
( ) max( ,0)NH s s N= •Preprocess for all Preprocess for all ii
vr
( ) ( ) ( ) ( , ) ( )NR v L s V s f s v H s d s= ∫r r r r r r r
( ) i iR v l t=∑r%
CSE 872 Fall 201156
Precomputed Radiance Transfer
Basis 16Basis 16
Basis 17Basis 17
Basis 18Basis 18
illuminateilluminate resultresult
......
......
CSE 872 Fall 201157
Subsurface ScatteringLighting effect
semi-translucent materialsskin, leaves, marble, milk, etc.
CSE 872 Fall 201158
BSSRDFGeneralization of BRDF
bidirectional surface scattering distribution function
entry and exit not identical
total outgoing radiance
CSE 872 Fall 201159
Subsurface ScatteringBig idea
break things down into single and multiple (diffuse) scattering eventshow does medium enter?
reduced intensity due to scatter
first order scattering as
volumetric source
CSE 872 Fall 201160
Diffusion of Lightintegrate transport equation over all
directions
two term expansion
after substitution into transport eq.
isotropic sources
CSE 872 Fall 201161
And The Winner Is?!You may now pick up your Oscar
Jensen, Marschner, Levoy, Hanrahan
CSE 872 Fall 201162
Making it Faster
CSE 872 Fall 201163
Texture Memory
Rasterization
Modern GPU Org.
Vertex ShaderGeometry
(vertex stream)
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
Pixel Shader
Frame Buffer
Tex 0
Tex 1
Tex 2
Setup
[John Hart]