41
computer graphics & visualization

Computer graphics & visualization. Raytracing … or where did my performance go? M.G. Chajdas

Embed Size (px)

Citation preview

computer graphics & visualization

Raytracing

… or where did my performance go?

M.G. Chajdas

Ray-tracing• Name says it all: Trace rays– Lots of rays– And some more

• Hardware vendors love it!

500 M rays!

Ray-tracing

Goal

The rendering equation• Total illumination from a position at time

with wavelength towards direction 𝐿𝑂 (𝑥 ,𝜔 ,𝜆 , 𝑡 )=𝐿𝑒 (𝑥 ,𝜔 ,𝜆 ,𝑡 )+∫

Ω

𝑓 𝑟 (𝑥 ,𝜔 ′ ,𝜔 ,𝜆 ,𝑡 )𝐿𝑖 (𝑥 ,𝜔′ ,𝜆 ,𝑡 ) ⟨−𝜔′ ,𝑛 ⟩d𝜔 ′

5D:BRDF

4D: LightResult1986

Rendering equation• If you think it‘s complex …• It doesn‘t capture:– Phosphoresence– Flurorescence– Intereference– Subsurface scattering

Solving the equation• Maple?• Matlab?

Rendering equation• What makes it complicated to evaluate?• Outgoing light depends on incoming light

𝑳𝑶 (𝑥 ,𝜔 ,𝜆 , 𝑡 )=𝐿𝑒 (𝑥 ,𝜔 ,𝜆 ,𝑡 )+∫Ω

𝑓 𝑟 (𝑥 ,𝜔′ ,𝜔 ,𝜆 , 𝑡 )𝑳𝒊 (𝑥 ,𝜔 ′ ,𝜆 , 𝑡 ) ⟨−𝜔′ ,𝑛⟩ d𝜔 ′

• I.e. it‘s recursive

Direct illumination• Simplify: We only use the term for the

evaluation; i.e. we only sample emitted light• No bounces, no recursion𝑳𝑶 (𝑥 ,𝜔 ,𝜆 , 𝑡 )=𝐿𝑒 (𝑥 ,𝜔 ,𝜆 ,𝑡 )+∫

Ω

𝑓 𝑟 (𝑥 ,𝜔′ ,𝜔 ,𝜆 , 𝑡 )𝑳𝒊𝑬 (𝑥 ,𝜔′ ,𝜆 , 𝑡 ) ⟨−𝜔′ ,𝑛 ⟩ d𝜔′

𝑳𝑶 (𝑥 ,𝜔 ,𝜆 , 𝑡 )=𝐿𝑒 (𝑥 ,𝜔 ,𝜆 ,𝑡 )+ ∑𝜔 ′⊂Ω

𝑓 𝑟 (𝑥 ,𝜔′ ,𝜔 , 𝜆 , 𝑡 )𝑳𝒊𝑬 (𝑥 ,𝜔′ ,𝜆 ,𝑡 ) ⟨−𝜔 ′ ,𝑛 ⟩

Global illumination

Loss of energy with more bounces!

Global illumination

∫Ω

𝒇 𝒓 ( 𝒙 ,𝝎 ′ ,𝝎 ,𝝀 ,𝒕 )Li❑ (x ,ω ′ , λ , t ) ⟨−𝜔′ ,𝑛 ⟩d𝜔 ′

=( > 0)

Mirror-BRDF:

Global illumination

∫Ω

𝒇 𝒓 ( 𝒙 ,𝝎 ′ ,𝝎 ,𝝀 ,𝒕 )Li❑ (x ,ω ′ , λ , t ) ⟨−𝜔′ ,𝑛 ⟩d𝜔 ′

=1

Diffuse-BRDF:

How to get it fast?• Clever sampling• Clever intersections

Sampling

Intersections

Intersections• Classic search problem• Trees to the rescue– Space partitioning: Subdivide the space– Object partitioning: Group objects

BSP

BSP

struct Plane{ float normal [3]; float dist;};

struct Node{ int plane; int children [2]; int boundingBoxMin [3]; int boundingBoxMax [3];};

struct Leaf{ int cluster; int area; int boundingBoxMin [3]; int boundingBoxMax [3]; int firstFaceIndex; int faceCount; int firstBrushIndex; int brushCount;};

Use the source, Luke!

BVH

BVH

Raytracing, recap• Raytracing can solve the rendering equation– It can simulate all light transport paths

• Requires lots of rays– Sample the important directions only, so less rays

are wasted– Build acceleration structures so each individual ray

is cheap

Raytracing, limitations

Questions?