Ray Tracing with Existing Graphics Systems Jeremy Sugerman

  • Slides: 23
Download presentation
Ray Tracing with Existing Graphics Systems Jeremy Sugerman, FLASHG 31 January 2006 1

Ray Tracing with Existing Graphics Systems Jeremy Sugerman, FLASHG 31 January 2006 1

Why Consider Tracing Rays? n Some techniques are hard to mimic with rasterization. Shadows

Why Consider Tracing Rays? n Some techniques are hard to mimic with rasterization. Shadows (arbitrary view visibility) n Reflection, Refraction effects n Global, Indirect Illumination n 2

Why Now? Raytracing is getting fast enough to use interactively. n New architectures seem

Why Now? Raytracing is getting fast enough to use interactively. n New architectures seem potentially suited or not too far from being suited. n 3

“Interactive”, Really? n Intel MLTRA (SIGGRAPH 2005) ¨ 20 -36 fps (20 -36 MRays/sec)

“Interactive”, Really? n Intel MLTRA (SIGGRAPH 2005) ¨ 20 -36 fps (20 -36 MRays/sec) on one 3. 2 GHz ¨ Without MLTRA, still 7 -12 fps / MRays/sec n My toy SSE raytracer ¨ About n 2 MRays/sec (primary rays) ‘Quick Hack’ Cell system at SIGGRAPH ¨ Claims 20 -25 fps / MRays/sec (unreviewed) 4

What about Rasterization? 60+ fps over 1024 x 768 on $99 GPUs n Ray

What about Rasterization? 60+ fps over 1024 x 768 on $99 GPUs n Ray tracing would need 50+ MRays/sec casting primary rays alone. n GPUs are getting faster at a phenomenal rate. n n Ray tracing is DOOMED! 5

It’s Not About Rasterization The vast majority of render time is actually shading in

It’s Not About Rasterization The vast majority of render time is actually shading in most 3 D apps. n True for offline rendering too. n Whether fragments are rasterized or ray traced, shading is the same… n n To the extent the fragments are the same 6

And Who Traces Primary Rays? n n We want ray tracing for shadows, reflection/refraction,

And Who Traces Primary Rays? n n We want ray tracing for shadows, reflection/refraction, and indirect illumination. Those are all applications of secondary rays. The rasterizer already produces (x, y, z), normals, etc. from primary hits. Might as well rasterize them if you have a fast existing mechanism. It doesn’t matter. 7

Synthesis (Thesis + Antithesis) n n Bolt a ray tracer onto a conventional rasterization

Synthesis (Thesis + Antithesis) n n Bolt a ray tracer onto a conventional rasterization based system. Add a bit of ray tracer friendliness to a GPU. Or, wire together a Cell and a GPU (don’t tell Sony). Window systems (2 D), text are rasterization tasks fundamentally (plus optional compositing) 8

“Ray Tracer Friendliness”? Ray tracing strongly favours threaded architectures over SIMD. n Packet tracing

“Ray Tracer Friendliness”? Ray tracing strongly favours threaded architectures over SIMD. n Packet tracing leverages bandwidth at the cost of very simple horizontal communication. n Being able to use queues / write buffers seems critical. n 9

How Would It Work? n Operate on ‘hits’ ¨ Analogous n to fragments, plus

How Would It Work? n Operate on ‘hits’ ¨ Analogous n to fragments, plus weights Each hit feeds any of three (independent) shading choices ¨ Gather rays ¨ Shadowing and local lighting contribution ¨ Secondary rays n Each produces a colour and a weight which are accumulated into a final pixel colour 10

Shadowing And Local Lighting n Effectively runs: Interpolate shading data (BRDF, Normal, etc. )

Shadowing And Local Lighting n Effectively runs: Interpolate shading data (BRDF, Normal, etc. ) n Generate as many shadow rays as are desired n Foreach shadow ray { n If (shadow ray hits light) { Compute local light contribution from the light } Fits in the same per-fragment storage n Shadow computations are indepedent n 11

Gather and Secondary Rays Gather rays just perform a weighted lookup in a data

Gather and Secondary Rays Gather rays just perform a weighted lookup in a data structure (e. g. photon map) n Secondary rays are generated based on the surface shading information (BRDF, Normal, …) n ¨ Hits are fed back into the same pipeline ¨ Once generated, independent of parent 12

Kinda Like a GPU (If you squint) n n GPU shading just does the

Kinda Like a GPU (If you squint) n n GPU shading just does the weighted local lighting calculation. But a fragment program can generate and trace shadow rays to mask local lighting And a fragment program can generate rays for final gathers. All this formulation does is expose parallelism and offer natural places to optimize hardware 13

I Saw You Palm That Card! n Secondary rays are a bit harder to

I Saw You Palm That Card! n Secondary rays are a bit harder to cram into a fragment program. ¨ No n variable output buffers recursion Once generated, secondary rays are completely independent. ¨ Only need an unordered write buffer ¨ No state, so recursion becomes iteration n So start with only shadow and gather rays ¨ Exact same system supports them, though 14

What About Coherence? n n Rasterization lie: Rasterization systems exploit coherence vastly better than

What About Coherence? n n Rasterization lie: Rasterization systems exploit coherence vastly better than ray tracing. Really means shading coherence ¨ Coherence between fragments in texture lookups ¨ Can bind a single material shader and rasterize only relevant geometry ¨ Can perform (expensive!) shading math at a different resolution than visibility math. 15

Ray Tracing Is Coherent Too Packet tracing is useful because of visibility coherence. n

Ray Tracing Is Coherent Too Packet tracing is useful because of visibility coherence. n The same coherence is also somewhat relevant for local shading and lighting. n Even, render only objects with the same material in each pass and z-cull. n ¨ Just as coherent as rasterization 16

Ray Tracing Is Coherent Too Packet tracing literature demonstrates ray coherence helps visibility most,

Ray Tracing Is Coherent Too Packet tracing literature demonstrates ray coherence helps visibility most, but also shadow / secondary rays and shading. n Rasterization systems save overdraw by rendering a depth-only pass before material shading with z-culling. n The same technique works with rays! n 17

Global Effects Are Incoherent n Nearly by definition, indirect and interobject shading effects are

Global Effects Are Incoherent n Nearly by definition, indirect and interobject shading effects are incoherent. ¨ In rasterization or ray-traced systems! Packet tracing literature indicates secondary rays retain some coherence. n Geometry level of detail can regain coherence. n 18

Coherence: Bottom Line Without secondary rays, ray tracing shares the coherence characteristics of rasterization

Coherence: Bottom Line Without secondary rays, ray tracing shares the coherence characteristics of rasterization (modulo implementation). n With secondary rays, ray tracing offers natural mechanisms for effects that are only awkwardly kludged via rasterization. n Let the developer / director pick the tradeoff. n 19

What Needs To Be Done? n n n Persuade Pat to get a PS

What Needs To Be Done? n n n Persuade Pat to get a PS 3 dev kit? Get a good ray tracer running on Cell and/or a GPU. Simulate various extensions ¨ Cram code in fragment programs ¨ Readback to the CPU for now ¨ Readback to a Cell ¨ Talk to the Smart Memories folks? ¨ Talk to GPU vendors (unlikely, they’re busy folks) 20

What’s Behind the Curtain? n K-d tree building and updates ¨ But, n n

What’s Behind the Curtain? n K-d tree building and updates ¨ But, n n Rasterization systems do this today K-d tree storage and bandwidth needs Hardware changes for traversing k-d trees or intersecting triangles ¨ Unclear n n if it’s even necessary initially Level of detail with secondary rays Decoupling visibility and shading resolutions 21

Contributions and Inspirations Tim, Pat n Gordon Stoll n Bill Mark n Phil Slusallek

Contributions and Inspirations Tim, Pat n Gordon Stoll n Bill Mark n Phil Slusallek and the Saarland crew n Tim Purcell, John Nickolls (NVIDIA) n 22

Rasterization Lies n n n Rasterization has coherence Ray tracing lacks. The rasterization argument

Rasterization Lies n n n Rasterization has coherence Ray tracing lacks. The rasterization argument goes: rasterize all the geometry of a given material and there’s excellent coherence of shading samples. Without secondary rays, ray tracing is the same. With secondary rays, you get better pictures. The programmer gets to choose. 23