001introduction of Rendering
001introduction of Rendering
Ray Casting
The Story So Far
3D Modeling
Wireframes, surface, splines, meshes,
constructive solid geometry
Animation
Key-framing, Rigging, Skinning,
Motion Capture, Particle Systems
Now we’ll to see how to generate
an image given a scene description!
Today
What does rendering mean?
Scene
Image: Nikon D40
Image
Image
Image
Image
Camera and
Ray Casting Basics Ray-Sphere Intersection
Ray Generation
origin
Ray Casting
For every pixel
Construct a ray from the eye
Ray Casting
For every pixel
Construct a ray from the eye
For every object in the scene
Find intersection with the ray
Ray Casting
For every pixel
Construct a ray from the eye
For every object in the scene
Find intersection with the ray
Keep if closest
Ray Casting
For every pixel
Construct a ray from the eye
For every object in the scene
Find intersection with the ray
Keep if closest
Shade
Ray Casting
For every pixel
Construct a ray from the eye
Ray Casting
For every pixel
Construct a ray from the eye
For every object in the scene
Find intersection with the ray
Ray Casting
For every pixel
Construct a ray from the eye
For every object in the scene
Find intersection with the ray
Keep if closest
Ray Casting
For every pixel
Construct a ray from the eye
For every object in the scene
Find intersection with the ray
Keep if closest
Shade
Ray Casting
For every pixel
Construct a ray from the eye
For every object in the scene
Find intersection with the ray
Keep if closest
Shade
Shading = What Surfaces Look Like
Surface/Scene Properties N
L
surface normal (N) V
direction to light (L)
Viewpoint (V)
Material Properties
Diffuse (matte)
Specular (shiny)
…
Light properties
Position
Intensity, ...
Much more! Diffuse sphere Specular spheres
Ray Casting vs. Ray Tracing
Let’s think about shadows...
?
“camera rays” Image: Nikon D40
are rays from the
camera to the
scene
Ray Casting vs. Ray Tracing
Shadows
Secondary Rays
Secondary Rays
Reflections
Image by Henrik Wann Jensen
Shadows
Secondary Rays
Reflections Refractions
Image by Henrik Wann Jensen
Shadows
Secondary Rays
Reflections Refractions
Image by Henrik Wann Jensen
Shadows
Caustics
Secondary Rays
Indirect
illumination
Reflections Refractions
Image by Henrik Wann Jensen
Shadows
Caustics
Secondary Rays
Indirect
illumination
Reflections Refractions
Image by Henrik Wann Jensen
Shadows
Caustics
Reflections
Ray Tracing
Caustics
Ray Casting
For every pixel
Construct a ray from the eye
For every object in the scene
Find intersection with the ray
Keep if closest
Shade depending on light and normal vector
N
Finding the
intersection point
and normal is the
central part of ray
casting
Ray Representation
Origin – Point How would you
Direction – Vector represent a ray?
normalized is better
Parametric line
P(t) = origin + t * direction
P(t)
direction
origin
Ray Representation
Origin – Point Another way to put
the ray casting
Direction – Vector
problem statement:
normalized is better Find smallest t such
Parametric line that P(t) lies on a
P(t) = origin + t * direction surface in the
scene
P(t)
direction
origin
Ray Representation
Origin – Point Another way to put
the ray casting
Direction – Vector
problem statement:
normalized is better Find smallest t such
Parametric line that P(t) lies on a
P(t) = origin + t * direction surface in the
scene
t should be > 0
P(t)
direction
origin
Ray Representation
Origin – Point Another way to put
the ray casting
Direction – Vector
problem statement:
normalized is better Find smallest t such
Parametric line that P(t) lies on a
P(t) = origin + t * direction surface in the
scene
t should be > 0
P(t)
direction
Explicit origin
representation
Dürer’s Ray Casting Machine
Albrecht Dürer, a German painter, 16th century
Image: New York Public Library/Science Source, Perspective Projection, Albrecht Dürer, 1532
Ray Casting
Camera and
Ray Casting Basics Ray-Sphere Intersection
Ray Generation
origin
Cameras
For every pixel
Image by Abelardo Morell, copyright reserved. Transforming a room into camera obscura
www.abelardomorell.net https://youtu.be/X9_6EbucCPQ
Simplified Pinhole Camera
Eye-image pyramid (view frustum)
*the distance/size of image are arbitrary
same image
will result on
this image plane
4
Camera Description?
Camera Description?
Eye point e (center)
Orthobasis u (horizontal), v (up), w (direction)
e w
u
Camera Description?
Eye point e (center)
Orthobasis u (horizontal), v (up), w (direction)
Field of view angle
Image rectangle aspect ratio
v
e w
u
Perspective vs. Orthographic
perspective orthographic
Perspective vs. Orthographic
orthographic perspective
Reference: Jia, Jia & Liu, Juan & Jin, Guofan & Wang, Yongtian. (2014). Fast and effective occlusion culling for 3D holographic
displays by inverse orthographic projection with low angular sampling. Applied Optics. 53. 10.1364/AO.53.006287.
Orthographic Camera
Ray Generation?
Orthographic Camera
Ray Generation?
Origin = e + x*size*u + y*size*v
Direction is constant: w
𝜈Ԧ
w
e
𝑢
Orthographic Camera
Ray Generation?
Origin = e + x*size*u + y*size*v
Direction is constant: w
𝜈Ԧ
w
origin
e
𝑢
Other Weird Cameras
E.g. fish eye, omnimax
Image from Wikipedia Omnimax Shows, Source: Hong Kong Space Museum
Ray Casting
Camera and
Ray Casting Basics Ray-Sphere Intersection
Ray Generation
origin
Sphere Representation?
Implicit sphere equation Equations in three-dimensional space:
Rd Ro
Ray-Sphere Intersection
Ray: P(t) = Ro + t*Rd ; Sphere H(P) = P·P - r2 = 0
Insert explicit equation
of ray into
implicit equation of sphere & solve for t
(Ro + tRd) · (Ro + tRd) - r2 = 0
Rd·Rdt2 + 2Rd·Rot + Ro·Ro - r2 = 0
Rd Ro
Ray-Sphere Intersection
Quadratic: at2 + bt + c = 0
a = 1 (remember, ||Rd|| = 1)
b = 2Rd·Ro
c = Ro·Ro – r2
with discriminant
and solutions
Ray-Sphere Intersection
3 cases, depending on the sign of b2 – 4ac
What do these cases correspond to?
Which root (t+ or t-) should you choose?
Closest positive!
Ray-Sphere Intersection
It's
so easy that all
ray-tracing images
have spheres!
Turner Whitted
Ray-Sphere Intersection
It's
so easy that all
ray-tracing images
have spheres!
Other shapes follow
the same manner
Turner Whitted
Sphere Normal
Simply Q/||Q||
Q = P(t), intersection point
(for spheres centered at origin)
Rd Ro
Q
normal