other rendering techniquescse872/rendering.pdfcse 872 fall 2011 5 raytracing •arthur appel in 1968...

32
CSE 872 Fall 2011 1 Other Rendering Techniques CSE 872 Fall 2011 2 Intro You have seen •Scanline converter (+z-buffer) •Painter’s algorithm •Radiosity

Upload: others

Post on 27-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

CSE 872 Fall 20111

Other Rendering Techniques

CSE 872 Fall 20112

Intro

You have seen•Scanline converter (+z-buffer)•Painter’s algorithm•Radiosity

Page 2: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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.

Page 3: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

Page 4: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

Page 5: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

}

Page 6: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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?

Page 7: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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?

Page 8: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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…

Page 9: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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?

Page 10: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

Page 11: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

CSE 872 Fall 201121

Spatial subdivisionsUniform divisions

All boxes are equal sizedAdvantages? Disadvantages?

Non-uniform divisionsHow? Why?

CSE 872 Fall 201122

Octtree-based

Page 12: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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?

Page 13: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

Page 14: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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…

Page 15: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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]

Page 16: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

Page 17: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

Page 18: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

Page 19: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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]

Page 20: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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]

Page 21: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

CSE 872 Fall 201141

Final Gathering

•Radiance Computation•Distributed ray tracing

[Jensen]

CSE 872 Fall 201142

Another example

[Jensen00]

Page 22: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

Page 23: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

Page 24: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

CSE 872 Fall 201147

Reyes Algorithm

read model

dice

shade

visibility

picture

texture

sample

CSE 872 Fall 201148

Micropolygons

Page 25: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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 =

Page 26: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

CSE 872 Fall 201151

Shadow Maps

CSE 872 Fall 201152

Deep Shadow Maps

3D texture where each point is how much illumination we receive

Page 27: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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]

Page 28: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

......

......

Page 29: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

Page 30: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

Page 31: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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

Page 32: Other Rendering Techniquescse872/rendering.pdfCSE 872 Fall 2011 5 Raytracing •Arthur Appel in 1968 Ray casting •Turner Whitted Q“An improved illumination model for shaded display”

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]