Understanding Ray Tracing: Shadows, Specular Reflections, and Refractive Transmission, Study notes of Computer Graphics

The concepts of shadows, specular reflections, and refractive transmission in the context of ray tracing. It covers the phong illumination model, the importance of recursively tracing rays, and the calculation of refracted directions. The document also discusses the limitations of opengl's support for transparency and the importance of snell's law in refraction.

Typology: Study notes

Pre 2010

Uploaded on 03/16/2009

koofers-user-1b0-3
koofers-user-1b0-3 🇺🇸

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Looking at the Shading Model
Recall our current Phong illumination model
• sums contributions from all lights
• plus the global ambient glow
We’ll add three important new components
• shadows, specular reflections, and specular transmission
• our general strategy: recursively trace rays to evaluate shading
• hence we call the method (recursive) ray tracing
diffuse reflection
all lights specular highlight
() ()
n
Ld Ls
L
IIk Ik=⋅+⋅
∑
nL rv


L
n
θ
v
r
φ
Refractive Transparency
OpenGL supports limited transparency
• enable alpha blending
• render objects back to front
Doesn’t account for refraction
• light rays bent at material boundaries
• accounts for lenses among other
Can account for refraction like reflection
• when shading a given point
• trace a transmitted ray into the material
• need to compute refracted direction
Air Glass Air
Refraction of Light
Rays transitioning between materials are bent around normal
• every material has an index of refraction
Angles with surface normal obey Snell’s Law
where are indices of refraction
sin
sin
it
ti
ti
θ
Ρ
ΡΡ
θΡ
==
n
i
θ
t
θ
T
I
Material Index of Refraction
vacuum 1.0
ice 1.309
water 1.333
ethyl alcohol 1.36
glass 1.5–1.6
diamond 2.417
Refraction of Light
Refractive indices determine amount of bending
• going from low index to higher index
– ray is bent towards the normal
– for example: air to glass
• going from high index to lower index
– ray is bent away from the normal
– for example: glass to water
Technically, this is a function of wavelength
• that’s why prisms work (and why you see rainbows)
• but for our purposes here, we’ll ignore this detail
pf3
pf4
pf5

Partial preview of the text

Download Understanding Ray Tracing: Shadows, Specular Reflections, and Refractive Transmission and more Study notes Computer Graphics in PDF only on Docsity!

Looking at the Shading Model Recall our current Phong illumination model

  • sums contributions from all lights• plus the global ambient glow We’ll add three important new components - shadows, specular reflections, and specular transmission• our general strategy: recursively trace rays to evaluate shading• hence we call the method (recursive) ray tracing

diffuse reflection all lights

specular highlight

(^

)^

(^

n )

L^ d

L^ s

L I^

I k

I k

=^

⋅^

+^

∑

n L

r v

L

n θ

v r φ

Refractive Transparency OpenGL supports limited transparency

  • enable alpha blending• render objects back to front Doesn’t account for refraction - light rays bent at material boundaries• accounts for lenses among other Can account for refraction like reflection - when shading a given point• trace a transmitted ray into the material• need to compute refracted direction

Air

Glass

Air

Refraction of Light Rays transitioning between materials are bent around normal

  • every material has an index of refraction Angles with surface normal obey Snell’s Law

where

are indices of refraction

sinsin

i^

t ti t^

i

θ

Ρ Ρ

Ρ

θ

Ρ =^

n i θ

θ^^ t

T

I

Material

Index of Refraction

vacuum

ice

water

ethyl alcohol

glass

diamond

Refraction of Light Refractive indices determine amount of bending

  • going from low index to higher index
    • ray is bent towards the normal– for example: air to glass
      • going from high index to lower index
        • ray is bent away from the normal– for example: glass to water Technically, this is a function of wavelength - that’s why prisms work (and why you see rainbows)• but for our purposes here, we’ll ignore this detail

Computing the Transmitted Ray Angles of the incoming & transmitted rays obey Snell’s Law

  • this isn’t terribly convenient• need transmitted direction

vector

With a little math, we can derive the transmitted direction

sinsin

i^

t ti t^

i

θ

Ρ Ρ θ

Ρ =^

=^

n i θ

θ^^ t

T

I

(^

where

and

(^

cos

i

i

t

c^

c

c Ρ^

Ρ

Ρ^

Ρ

θ

Ρ^

Ρ

2

2

=^

+^

−^

=^

T^

I^

n n I

One Last Refractive Detail When entering material of lower index

  • ray bends outward from normal• what if the angle is more than 90°?
    • ray is actually reflected off the boundary– this is called total internal reflection– and it’s why fiber optics work Total internal reflection occurs when - just need to check for this critical angle• if above it, use specular reflection for “transmission”• if we’re exactly at the critical angle, things are a little weird

θ^ i

θ^ t

critical

critical

where

sin

t

i

Ρ i

θ^

θ

θ^

−1 η

>^

Classification of Rays We’ve now seen four kinds of rays in the world

  • eye rays that leave the eye through a pixel• reflected rays that bounce off surfaces• transmitted rays that travel through them• shadow rays which test for occluders Every surface intersection spawns - 1 reflected ray• 1 transmitted ray• 1 shadow ray per light

eye ray

reflected

ray

shadowray transmitted ray

Ray Recursion Recursive ray tracing spawns a whole tree of rays

  • when eye ray hits a surface, we spawn reflected &transmission rays• when either of them hits a surface, they spawn 2 more• typically impose maximum recursion limit We will wind up tracing

a lot

of rays

Ray Tracing Efficiently The primary path to efficiency

  • avoid tracing rays whenever possible• and above all, avoid ray–surface intersection tests A ray tracing system can be easily overcome with rays - minimum 1 eye ray per pixel, many more with supersampling• recursion depth

k^ yields

k 2

+1^ − 1

rays traced per eye ray

  • counting reflection & transmission rays but

not

shadow rays

Consider this example

  • image resolution of 1024x768 = 786,432 pixels• 3x3 supersampling = 7 million eye rays• recursion depth 5 = 63*7 = 441 million• each tested against 10,000 polygons• 4.4 trillion intersection tests (ignoring shadow rays)

Spatial Data Structures Probably the single most important efficiency improvement

  • divide space into cells• record what geometry lies in each cell• first test rays against cell• only check geometry within cell if the ray actually hits the cell Several data structures in common practice - hierarchical bounding volumes• BSP trees• octrees• regular 3-D grids

Hierarchical Bounding Volumes Begin by intersecting ray with the root volume

  • if no intersection, ignore all child volumes• otherwise, recursively test child volumes We’ll only test objects whose bounding volume is actually hit by ray - hopefully ignoring most of the scene• but this depends a lot on the structure of the hierarchy

BSP Trees, Octrees, and Grids Use BSP tree to traverse scene from front to back

  • start at root plane• figure out which side the viewpoint is on• descend on that side first; do this recursively Helps us avoid unnecessary work - can tell when closest intersection found• because we’re going front to back Can use grids & octrees similarly - traverse grid with 3-D DDA algorithm• octree a little trickier

C

Recall the Structure of Shading Procedure rgbColor shade(surface s, ray r, double t)

point x = r(t)rgbColor color = blackfor each light source L if( closest_hit(shadow_ray(x, L)) >= distance(L) )

color += shade_phong(s, x) color += k_specular * trace(reflected_ray(s,r,x))color += k_transmit * trace(transmitted_ray(s,r,x))return color What does this simulate?

  • Phong illumination+shadows (direct lighting of plastic)• perfect specular reflection (mirrors, chrome)• perfect specular transmission (glass, crystal)

Distributed Ray Tracing A powerful method for extending classical ray tracing

  • also known as distribution ray tracing & stochastic ray tracing• has

nothing

to do with parallel computation over a network

Simulate phenomena by distributing multiple rays

  • …over a pixel for spatial antialiasing• …over time for temporal antialiasing• …over a light source to simulate soft shadows• …over a cone of directions for glossy reflections• …over a lens for depth of field To get good results we must do this with care - select a good method for distributing rays• don’t want number of rays traced to expand out of control

From the First Distributed Ray Tracer Note the various phenomena

  • glossy reflections• soft shadows• motion blur
    • including of reflections
      • antialiasing is implicit• used 16 samples/pixel

Glossy Reflections Our current method simulates perfect specular reflection

  • is only really true for perfect mirrors• simulates metals like chrome fairly well Most surfaces are imperfect specular reflectors - reflect rays in cone around perfect reflection direction• glossy reflections rather than mirror images• Phong model tries to fake this kind of thing We can directly simulate real glossy reflection - for an incoming ray direction - instead of always shooting ray in perfect reflected direction– stochastically sample rays within cone of reflected directions - strength of reflection drops off rapidly from mirror direction• probability of sampling that direction should fall off similarly