Title: CSE 681 Refraction
1CSE 681Refraction
2Transparency
3Refraction
- Transparency depends upon the refractive
properties of the material - Light bends through some materials
4Snells Law
- Willebrord Snell (Dutch Physicist) determined
how light refracts through a medium in 1621
5Snells Law
- The angle at which the light bends is described
by the following relationship
qi Incident angle qt Refractive angle hr
Refractive index of the medium light is
entering hi Refractive index of the medium
light is leaving
6Refraction (Ray Tracing)
- Since we are following rays from the eye to the
light, we refract using the view vector - Cast a secondary ray (refractive ray)
- Incorporate the color from this ray into our
shading
7Refraction
- How do we compute the refraction vector T?
8Geometric Construction
- Assume all given vectors are unit vectors
- Define vector M that is to N
9Geometric Construction
- Project T onto M
- Project T onto -N
10Geometric Construction
11Raytracing AlgorithmShadows, Reflection, and
Refraction
- Color shade( ray, recursionDepth )
-
- Initialize pixel color to background
- Intersect all objects
- If an intersection is found
- Initialize to ambient shading
- For each light
- Shoot shadow ray
- If not in shadow add diffuse and
specular - If ( recursionDepth lt MAXRECURSION)
- If (object is shiny)
- Trace reflection ray
- If (object is transparent)
- Trace transmittive ray
- Return color
12Raytracing PseudocodeShadows, Reflection, and
Refraction
Keep track of the depth of the ray tree
- Color shade( ray, recursionDepth )
-
- c background color
- intersectFlag FALSE
- for each object
- intersectFlag intersect ( ray, p )
- if intersectFlag is TRUE
- c ambient
- for each light source
- shadowFlag intersectShadowRay ( p )
- if shadowFlag is FALSE
- compute reflective ray R (or H)
- c diffuse
- c specular components
- if ( recursionDepth lt MAXRECURSION)
- if (object is shiny)
- compute reflection of the ray, R1
First illuminate the point
Dont spawn reflection ray past the pre-chosen
tree depth
R1 reflects the view vector Add the returned
color with a shininess factor
T depends upon the index of refraction Add the
returned color with a transmittance factor
13Wavelength
- Refraction (and reflection) is wavelength-dependen
t - Remember Newtons experiment
- Where rainbows come from
- So, compute separately for each component (i.e.,
r, g, b)
14The Ray Tree Recursion!
T3
Eye
R2
N2
T1
R3
R1
N3
L1
L2
L3
N1
L1
T1
R1
L3
L2
Ni surface normal Ri reflected ray Li shadow
ray Ti transmitted (refracted) ray
Eye
T3
R2
R3
15Infinite Recursion
- Stopping criteria
- Recursion depth
- Stop after some bounces
- Ray contribution
- Stop if transparency/transmitted attenuation
becomes too small - Usually do both
16Recursion for Reflection
1 recursion
0 recursion
2 recursions
17Simulate Physics?
- Wait, in physics, dont the photons go from the
light to the eye not the other way - What we do is backward ray tracing
18Forward Ray Tracing
- Start from the light source
- Low probability to reach the eye
- What can we do about it?
19Forward Ray Tracing
- Always send a ray to the eye
- Still not efficient
20Simulate Physics?
- Shadows of transparent objects
- Assume it is opaque
- Just multiply by transparency color but no
refraction - Ray Tracing is full of dirty tricks