Title: The photorealism quest
1The photorealism quest
- An introduction to ray-tracing
2The basic idea
Cast a ray from the viewers eye through each
pixel on the screen to see where it hits some
object
object
view-plane
Apply illumination principles from physics to
determine the intensity of the light that is
reflected from that spot toward the eye
eye of viewer
3Example a spherical object
- Mathematics problem How can we find the spot
where a ray hits a sphere? - We apply our knowledge of vector-algebra
- Describe spheres surface by an equation
- Describe rays trajectory by an equation
- Then solve this system of two equations
- There could be 0, 1, or 2 distinct solutions
4Describing the sphere
- A sphere consists of points in space which lie at
a fixed distance from a given center - Let r denote this fixed distance (radius)
- Let c ( cx, cy, cz ) be the spheres center
- If w ( wx, wy, wz ) be any point in space,
then distance( w, c ) is written w c - Formula w c sqrt( (w - c)(w - c) )
- Sphere is a set w e R3 (w-c)(w-c) r
5Describing a ray
- A ray is a geometrical half-line in space
- It has a beginning point b ( bx, by, bz )
- It has a direction-vector d ( dx, dy, dz )
- It can be described with a parameter t 0
- If w ( wx, wy, wz ) is any point in space,
then w will be on the half-line just in case
w b td for some choice of the
parameter t 0 .
6Computing the hit time
- To find WHERE a ray hits a sphere, we think of w
as a point traveling in space, and we ask WHEN
will w hit the shere? - We can substitute the formula for a point on
the half-line into our formula for points that
belong to the spheres surface, getting an
equation that has t as its only variable - Its easy to solve such an equation for t to
find when w hits the spheres surface
7The algebra details
- Sphere w c r
- Half-line w b td, t 0
- Substitution b td c r
- Replacement Let q c b
- Simplification td q r
- Square (td q)(td q) r2
- Expand t2 dd -2tdq qq r2
- Transpose t2 dd -2tdq (qq - r2) 0
8Apply Quadratic Formula
- To solve t2 dd -2tdq (qq - r2) 0
- Format At2 Bt C 0
- Formula t -B/2A sqrt( B2 4AC )/2A
- Notice there could be 0, 1, or 2 hit times
- OK to use a simplifying assumption dd 1
- Equation becomes t2 2tdq (qq r2) 0
- Application We want the earliest hit-time
t (dq) - sqrt( (dq)2 (qq r2) )
9Interpretations
half-line
w2
w1
b
c
half-line
A half-line that begins inside the sphere will
only hit the spgeres surface once
10Second example A planar surface
- Mathematical problem How can we find the spot
where a ray hits a plane? - Again we can employ vector-algebra
- Any plane is determined by a two entities
- a point (chosen arbitrarily) that lies in it, and
- a vector that is perpendicular (normal) to it
- Let p be the point and n be the vector
- Plane is the set w e R3 (w-p)n 0
11When does ray hit plane?
- Plane (w p)n 0
- Half-line w b td, t 0
- Substitution (b td p)n 0
- Replacement Let q p b
- Simplification (td q)n 0
- Expand tdn - qn 0
- Solution t (qn)/(dn)
12Interpretations
half-line
n
p
d
w
If a half-line begins from a point outside a
given plane, then it can only hit that plane once
(and it might possibly not even hit that plane
at all
half-line
13Achromatic light
- Achromatic light brightness, but no color
- Light can come from point-sources, and light can
come from ambient sources - Incident light shining on the surface of an
object can react in three discernable ways - By being absorbed
- By being reflected
- By being transmitted (into the interior)
14Illumination
- Besides knowing where a ray of light will hit a
surface, we will also need to know whether that
ray is reflected or absorbed - If the ray of light is reflected by a surface,
does it travel mainly in one direction? Or does
it scatter off in several directions? - Various surface materials react differently
15Some terminology
- Scattering of light (diffuse reradiation)
- color may be affected by the surface
- Reflection of light (specular reflection)
- mirror-like shininess, color isnt affected
16Geometric ingredients
- Normal vector to the surface at a point
- Direction vector from point to viewers eye
- Direction vector from point to light-source