0% found this document useful (0 votes)
23 views66 pages

001introduction of Rendering

Uploaded by

iimsheung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views66 pages

001introduction of Rendering

Uploaded by

iimsheung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

Introduction 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?

 Basics of ray casting


Image: Stanford bunny surface
mesh (courtesy of Stanford Univ.).

Scene
Image: Nikon D40

Image: Stanford bunny surface


mesh (courtesy of Stanford Univ.). Camera
Scene
Field of view

Discrete 2D array of pixels

Image: Nikon D40

Image: Stanford bunny surface


mesh (courtesy of Stanford Univ.).
Pixels Camera
Scene Image plane
Rendering = Scene to Image

Image

Image: Nikon D40

Image: Stanford bunny surface


mesh (courtesy of Stanford Univ.).
Pixels Camera
Scene Image plane
Rendering – Pinhole Camera

Image

Image: Nikon D40

Image: Stanford bunny surface


mesh (courtesy of Stanford Univ.).
Pixels Each pixel corresponds to
one ray. We need to figure
Scene out which scene point
each one hits.
Rendering

Image

Image: Nikon D40

Image: Stanford bunny surface


mesh (courtesy of Stanford Univ.).
Pixels What’s the
Scene color you put
in each pixel?
Rendering

Image

Image: Nikon D40

Image: Stanford bunny surface


mesh (courtesy of Stanford Univ.).
Pixels
Pixel Color
Determined by
Scene Lighting/Shading
Rendering
 “Rendering” refers to the entire
process that produces color values for pixels,
given a 3D representation of the scene
 Pixels correspond to rays; find the visible point along
each ray
“hidden surface problem” in older texts
“Visibility” - more modern term
 Assume (for now) a single ray per pixel
 Major algorithms: Ray casting and Rasterization
Ray Casting

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...

Image: Nikon D40


Ray Casting vs. Ray Tracing

?
“camera rays” Image: Nikon D40
are rays from the
camera to the
scene
Ray Casting vs. Ray Tracing

ray from light to hit


point is blocked, i.e.,
X point is in shadow

Image: Nikon D40


Ray Casting vs. Ray Tracing
 Ray casting = eye rays only

Image: Nikon D40


Ray Casting vs. Ray Tracing
 Ray casting = eye rays only, tracing = also secondary rays

Secondary rays are used for


X testing shadows, doing
reflections, refractions, etc.

Image: Nikon D40

We’ll do all this a little later!


Image by Henrik Wann Jensen

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

Image by Henrik Wann Jenson, 2001


Image by Turner Whitted

Image by Henrik Wann Jenson, 2000


Reflections, refractions

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

Mechanical ray casting Source: marbleheadarts.org


Dürer’s Ray Casting Machine
 Albrecht Dürer, 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 from Wikipedia: https://en.wikiquote.org/wiki/Girard_Desargues


Construct a ray from the eye
For every object in the scene
Find intersection with ray
Keep if closest
Pinhole Camera
 Box with a tiny hole  Perfect image if hole infinitely small
 Inverted image  Pure geometric optics
 Similar triangles  Nodepth of field issue
(everything in focus)
Oldest Illustration
 From Gemma Frisius, Astronomer, 1545

Use pin hole to study the solar eclipse


Also Called “Camera Obscura”

Camera obscura ("dark room”). Source: wellcome library


Camera Obscura Today

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

Image from: https://steemit.com/nature/@arielpr/the-most-beautiful-


perspective tree-tunnels-in-the-world

Foreshortening refers to the visual effect or optical illusion that an object or


distance appears shorter than it actually is because it is angled toward the viewer.
Perspective vs. Orthographic
 Parallel projection
 No foreshortening
 No vanishing point

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:

Assume centered at origin (easy to


translate) a sphere with center (x0, y0, z0) and
radius r is the locus of all points P(x, y, z)
H(P) = ||P||2 - r2 = P·P - r2 = 0
Reference: https://en.wikipedia.org/wiki/Sphere

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

You might also like