[go: up one dir, main page]

0% found this document useful (0 votes)
13 views78 pages

Lecture 3

The document outlines the CSC418/2504 Computer Graphics course, focusing on ray tracing techniques, including ray casting, intersection testing, and shading models like Lambertian and Blinn-Phong. It provides important announcements regarding assignments, TA office hours, and resources for students seeking help. Additionally, it encourages volunteer note-taking for accessibility services and discusses the principles of light and surfaces in computer graphics.

Uploaded by

Safe Attorney
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)
13 views78 pages

Lecture 3

The document outlines the CSC418/2504 Computer Graphics course, focusing on ray tracing techniques, including ray casting, intersection testing, and shading models like Lambertian and Blinn-Phong. It provides important announcements regarding assignments, TA office hours, and resources for students seeking help. Additionally, it encourages volunteer note-taking for accessibility services and discusses the principles of light and surfaces in computer graphics.

Uploaded by

Safe Attorney
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/ 78

CSC418/2504 Computer Graphics

Some Slides/Images adapted from Marschner and Shirley


Today: Ray Tracing
Announcements
MarkUs Access

If you don’t have MarkUs access still email the TAs

Subject: CSC418 Access to MarkUs

Assignment 2 is due this Friday

Assignment 3 is available now (due 01/02)

TA Office Hours: Thursday 2:30pm – 3:30pm, BA5287

TA Email Address: csc418tas@cs.toronto.edu


Where to Ask Questions
1. GitHub Issues Pages for Assignments
1. “I think there’s a bug in the starter code”
2. “The CMakeFile is missing”
3. “The code didn’t clone correctly”
2. Discussion board
1. “The lecture wasn’t clear”
2. “This assignment task is ambiguous”
3. TA Email List
1. ”I need an extension”
2. “I’d like to request a remark”
Things you should do before asking for help
1. Google any errors. 99% of the time the solution to your
problem is on the first page of google hits.
2. Look at the file output. Image file doesn’t open ? Write a
small example in ASCII format to disk and open it with a
text editor.
3. Build simple test cases and isolate the function or line of
code that is not working
4. Be aware that we cannot tell you how to implement
something. Only clarify explanations/theory behind the
assignments.
Accessibility Services needs dependable volunteer note-takers to assist students living with a
disability to achieve academic success!
Volunteers report that by giving to the U of T community their class attendance and note taking
skills improve.
All you have to do is attend classes regularly & submit your notes consistently:
1) Register Online as a Volunteer Note-Taker
at: https://clockwork.studentlife.utoronto.ca/custom/misc/home.aspx
2) Follow the link that says Volunteer Notetakers
3) Select your course and upload a sample of your notes
4) Once you have been selected as a note-taker you'll get an email notifying you to upload your
notes.
If you have any questions, please call us. Our office is open Monday-Friday 9:00am-5:00pm and
Tuesdays 9:00 AM-6:00 PM.
Email us at as.notetaking@utoronto.ca or call 416-978-6186 if you have questions or require any
assistance.
Volunteers may receive co-curricular credit or a certificate of appreciation.
Your support is much appreciated!
Any Questions ?
Today: Ray Tracing
Review Ray Casting
Intersection Testing for Groups of Objects
Point and Directional Lights
Shadows
Lambertian Shading Model
Blinn-Phong Shading Model
Reflection
Transparency and Refraction
Ray Casting

for each pixel


objectininthe
theimage
scene{{
for each pixel
Generate a rayin the image {
for each
if (object
objectaffects
in thepixel)
scene{{
if (Intersect ray with object) {
do something
} Set pixel colour
} }
} }
}
Ray Casting

for each pixel


objectininthe
theimage
scene{{
for each pixel
Generate a rayin the image {
for each
if (object
objectaffects
in thepixel)
scene{{
if (Intersect ray with object) {
do something
} Set pixel colour
} }
} }
}
Intersection Tests with Composite Objects
Intersection Tests with Composite Objects

Group 1
Ray Casting

for each pixel


objectininthe
theimage
scene{{
for each pixel
Generate a rayin the image {
for each
if (object
objectaffects
in thepixel)
scene{{
if (Intersect ray with object) {
do something
} Set pixel colour
} }
} }
}
Light and Surfaces
Light and Surfaces
Light and Surfaces

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
Light and Surfaces

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
Light and Surfaces

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
Lights
Two types of lights:
Directional Light:
Direction of light does not depend on the position of
the object. Light is very far away
Point Light
Direction of light depends on position of object relative
to light.
Directional Light

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
Point Light

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

l
l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

<latexit sha1_base64="(null)">(null)</latexit>
<latexit
Ray Casting

for each pixel


objectininthe
theimage
scene{{
for each pixel
Generate a rayin the image {
for each
if (object
objectaffects
in thepixel)
scene{{
if (Intersect ray with object) {
do something
} Set pixel colour
} }
} }
}
Shadows

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
WARNING: Numerical Precision

What are valid values t for the shadow ray?


Ray Casting

for each pixel


objectininthe
theimage
scene{{
for each pixel
Generate a rayin the image {
for each
if (object
objectaffects
in thepixel)
scene{{
if (Intersect ray with object) {
do something
} Set pixel colour
} }
} }
}
Light and Surfaces

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
Light and Surfaces

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

v<latexit sha1_base64="(null)">(null)</latexit>
<latexit
l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
Lambertian (Diffuse) Shading
Lambertian (Diffuse) Shading

the amount of energy from a light source that falls on an area of


surface depends on the angle of the surface to the light.

- Lambert (18th century)


Lambertian (Diffuse) Shading

the amount of energy from a light source that falls on an area of


surface depends on the angle of the surface to the light.

- Lambert (18th century)

T
L = kd max 0, n l
<latexit sha1_base64="(null)">(null)</latexit>
Self Shadowing

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

v
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
Lambertian (Diffuse) Shading

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit


v <latexit sha1_base64="(null)">(null)</latexit>
<latexit

l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

<latexit sha1_base64="(null)">(null)</latexit>
<latexit

T
L = kd max 0, n l
<latexit sha1_base64="(null)">(null)</latexit>
Specular Reflection
Blinn-Phong Shading Model

“The idea is to produce reflection that is at its brightest when v


and l are symmetrically positioned across the surface normal,
which is when mirror reflection would occur; the reflection
then decreases smoothly as the vectors move away from a
mirror configuration. ”
– Marschner and Shirley
Blinn-Phong Shading

h n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

v ✓ ✓
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

<latexit sha1_base64="(null)">(null)</latexit>
<latexit

<latexit sha1_base64="(null)">(null)</latexit>
<latexit
The Half Vector

v+l
h=
kv + lk
<latexit sha1_base64="(null)">(null)</latexit>
The Half Vector

v+l
h=
kv + lk
<latexit sha1_base64="(null)">(null)</latexit>

n
L/
<latexit sha1_base64="(null)">(null)</latexit>
✓h
Measuring the Angle

n
L = ks max (0,
<latexit sha1_base64="(null)">(null)</latexit>
(✓h ))
Measuring the Angle

n
L=
<latexit sha1_base64="(null)">(null)</latexit>
ks max (0, cos(✓h ))
Measuring the Angle

1
p = 1
p = 10
0.8 p = 100
p = 1000
n p
L=
<latexit sha1_base64="(null)">(null)</latexit>
ks max (0, cos(✓h )) 0.6

0.4

0.2

0
-2 -1 0 1 2
Measuring the Angle

1
p = 1
p = 10
0.8 p = 100
p p = 1000
T
L = ks max 0, n h)
<latexit sha1_base64="(null)">(null)</latexit>
0.6

0.4

0.2

0
-2 -1 0 1 2
Increasing p

Segmentation of Rough Surfaces using | McGunnigle and Chantler


Putting it All Together: The Full Blinn-Phong Model
Light obeys the superposition principle

Total amount of received light is sum of light from all


incoming sources.

L = Lambertian + Specular
<latexit sha1_base64="(null)">(null)</latexit>
Putting it All Together: The Full Blinn-Phong Model
Light obeys the superposition principle

Total amount of received light is sum of light from all


incoming sources.

T n p
L = kd max 0, n l +
<latexit sha1_base64="(null)">(null)</latexit>
ks max (0, cos(✓h ))
No Global Effects
Putting it All Together: The Full Blinn-Phong Model
Light obeys the superposition principle

Total amount of received light is sum of light from all


incoming sources.

T n p
L = ka + kd max 0, n l +
<latexit sha1_base64="(null)">(null)</latexit>
ks max (0, cos(✓h ))
Ambient Diffuse Specular Final

Wikipedia | Brad Smith


Ray Casting

for each pixel


objectininthe
theimage
scene{{
for each pixel
Generate a rayin the image {
for each
if (object
objectaffects
in thepixel)
scene{{
if (Intersect ray with object) {
do something
} Set pixel colour
} }
} }
}
Ray Traced Image
Ray Traced Image

Mirror Mirror

Mirror
Recursive Ray Tracing
Recursive Ray Tracing
Light and Surfaces

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
Light and Surfaces

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

✓r
<latexit sha1_base64="(null)">(null)</latexit>
✓i
<latexit sha1_base64="(null)">(null)</latexit>

l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
Light and Surfaces

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

?
l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

<latexit sha1_base64="(null)">(null)</latexit>
l
Light and Surfaces

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

T
n l
l
<latexit sha1_base64="(null)">(null)</latexit>

<latexit sha1_base64="(null)">(null)</latexit>
<latexit

<latexit sha1_base64="(null)">(null)</latexit>
l
Light and Surfaces

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

T
<latexit sha1_base64="(null)">(null)</latexit>
l + nn l
Light and Surfaces

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

T
<latexit sha1_base64="(null)">(null)</latexit>
l + 2nn l
Light and Surfaces

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

T
<latexit sha1_base64="(null)">(null)</latexit>
I + 2nn ( l)
for each
each object
pixel in the scene
image{{
pixeleach
for pixel=inrayTrace(
colour the imageviewRay,
{ 0)
} if (object affects pixel) {
colour rayTrace(Ray, depth) {
for each object in the scene {
if(Intersect ray with object) {
colour = shading model
if(depth < maxDepth)
colour += rayTrace(reflectedRay,depth+1)
}
}
return colour
}
Ray Spawning

https://www.scratchapixel.com/lessons/3d-
basic-rendering/ray-tracing-overview/light-
transport-ray-tracing-whitted
Transparency and Refraction
Transparency and Refraction

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit
Transparency and Refraction

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

✓l
<latexit sha1_base64="(null)">(null)</latexit>

l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

t
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

✓t
<latexit sha1_base64="(null)">(null)</latexit>
Snell’s Law

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

cl sin ✓l = ct sin ✓t
<latexit sha1_base64="(null)">(null)</latexit>
✓l
<latexit sha1_base64="(null)">(null)</latexit>

Indices of Refraction l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

t
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

✓t
<latexit sha1_base64="(null)">(null)</latexit>
Computing the Refracted Ray

n
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

t = tk + t?
<latexit sha1_base64="(null)">(null)</latexit>
✓l
<latexit sha1_base64="(null)">(null)</latexit>

|t| = 1 l
tk
<latexit sha1_base64="(null)">(null)</latexit>

<latexit sha1_base64="(null)">(null)</latexit>
<latexit

<latexit sha1_base64="(null)">(null)</latexit>

t
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

t?
<latexit sha1_base64="(null)">(null)</latexit>

✓t
<latexit sha1_base64="(null)">(null)</latexit>
Computing the Refracted Ray ✓l
<latexit sha1_base64="(null)">(null)</latexit>

tk = sin ✓t
<latexit sha1_base64="(null)">(null)</latexit>

cl
l
tk
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

tk = sin ✓l
ct
<latexit sha1_base64="(null)">(null)</latexit>

<latexit sha1_base64="(null)">(null)</latexit>

t
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

t?
<latexit sha1_base64="(null)">(null)</latexit>

✓t
<latexit sha1_base64="(null)">(null)</latexit>
Computing the Refracted Ray ✓l
<latexit sha1_base64="(null)">(null)</latexit>

tk = sin ✓t
<latexit sha1_base64="(null)">(null)</latexit>

cl
l
tk
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

tk = sin ✓l lk
ct
<latexit sha1_base64="(null)">(null)</latexit>

<latexit sha1_base64="(null)">(null)</latexit>

<latexit sha1_base64="(null)">(null)</latexit>

cl
tk =
ct
lk t
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

t?
<latexit sha1_base64="(null)">(null)</latexit>

<latexit sha1_base64="(null)">(null)</latexit>

cl
tk = lk ✓t
ct
<latexit sha1_base64="(null)">(null)</latexit>
<latexit sha1_base64="(null)">(null)</latexit>
Computing the Refracted Ray ✓l
<latexit sha1_base64="(null)">(null)</latexit>

cl
tk = lk
ct l
tk
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

<latexit sha1_base64="(null)">(null)</latexit>

cl T lk
tk = l nn l <latexit sha1_base64="(null)">(null)</latexit>
<latexit sha1_base64="(null)">(null)</latexit>

<latexit sha1_base64="(null)">(null)</latexit>
ct
cl t
tk = (l cos ✓l n) <latexit sha1_base64="(null)">(null)</latexit>
<latexit

t?
ct
<latexit sha1_base64="(null)">(null)</latexit>

<latexit sha1_base64="(null)">(null)</latexit>

✓t
<latexit sha1_base64="(null)">(null)</latexit>
Computing the Refracted Ray ✓l
<latexit sha1_base64="(null)">(null)</latexit>

t = tk + t?
tk =
cl cl
<latexit sha1_base64="(null)">(null)</latexit>

l + cos ✓l n + t?
l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

ct ct <latexit sha1_base64="(null)">(null)</latexit>

t
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

t?
<latexit sha1_base64="(null)">(null)</latexit>

✓t
<latexit sha1_base64="(null)">(null)</latexit>
Computing the Refracted Ray ✓l
<latexit sha1_base64="(null)">(null)</latexit>

t = tk + t?
tk =
cl cl
<latexit sha1_base64="(null)">(null)</latexit>

l + cos ✓l n + t?
l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

ct ct <latexit sha1_base64="(null)">(null)</latexit>

t? = ↵n t
<latexit sha1_base64="(null)">(null)</latexit>

q <latexit sha1_base64="(null)">(null)</latexit>
<latexit

t?
<latexit sha1_base64="(null)">(null)</latexit>

2
t? = 1 sin ✓t n
<latexit sha1_base64="(null)">(null)</latexit>

✓t
<latexit sha1_base64="(null)">(null)</latexit>
Computing the Refracted Ray
cl cl
✓l
<latexit sha1_base64="(null)">(null)</latexit>

tk = l + cos ✓l n + t?
ct ct l
cl cl
<latexit sha1_base64="(null)">(null)</latexit>

<latexit sha1_base64="(null)">(null)</latexit>
<latexit

t= l + cos ✓l n cos ✓t n
ct ct
q
<latexit sha1_base64="(null)">(null)</latexit>

2
t? =
<latexit sha1_base64="(null)">(null)</latexit>

p
1 sin ✓t n t <latexit sha1_base64="(null)">(null)</latexit>
<latexit

t?
<latexit sha1_base64="(null)">(null)</latexit>

t? = 2
cos ✓t n

<latexit sha1_base64="(null)">(null)</latexit>

t? = <latexit sha1_base64="(null)">(null)</latexit>
cos ✓t n t <latexit sha1_base64="(null)">(null)</latexit>
Computing the Refracted Ray ✓l
<latexit sha1_base64="(null)">(null)</latexit>

✓ ◆
cl cl
t=
<latexit sha1_base64="(null)">(null)</latexit>
ct
l+
ct
cos ✓1 cos ✓t n l
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

t
<latexit sha1_base64="(null)">(null)</latexit>
<latexit

t?
<latexit sha1_base64="(null)">(null)</latexit>

✓t
<latexit sha1_base64="(null)">(null)</latexit>
colour rayTrace(Ray, depth) {
for each object in the scene {
if(Intersect ray with object) {
colour = shading model
if(depth < maxDepth) {
colour += rayTrace(reflectedRay,depth+1)
colour += rayTrace(refractedRay,depth+1)
}
}
}
return colour
}
Ray Spawning

https://www.scratchapixel.com/lessons/3d-
basic-rendering/ray-tracing-overview/light-
transport-ray-tracing-whitted
Done for Today
Office hours are now BA5268
Assignment 2 due this Friday
Assignment 3 available now

You might also like