









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
How to implement reflection and transparency in raytracing. It covers the calculation of reflected and transmitted components of light, the determination of reflection and transmitted directions, and the recursive shading function. It also discusses the importance of snell's law and critical angles.
Typology: Slides
1 / 16
This page cannot be seen from the preview
Don't miss anything!










Computer Graphics Raytracing (Part 4)
n Ray tracing also handles reflections and refraction of light well n We can easily render realistic scenes with n mirrors, n martini glasses n So, far, we have considered Local components (ambient, diffuse, specular) n Local components are contributions from light sources which are visible from hit point n To render reflection, and refraction we need to add reflection and refraction components of light
n r is given as (see eqn 4.22) as
n Transmitted component IT
is along transmitted direction t
n Portion of light coming in from
direction t is bent along dir
n IR and IT each have their own
five components (ambient, diffuse, etc)
n In some sense, point P’ along reflected
direction r serves as a light source to point Ph
Ph
v
r
m
s
dir
t
IR
IT
I
P’
n To determine reflected component
n Spawn reflected ray along direction r n Determine closest object hit
n To determine transmitted component
n Cast transmitted ray along direction t n Determine closest object hit
n So, at each hit point, local, reflected
and refracted components merge to form total contributions
Ph
v
r
m
s
dir
t
IR
IT
I
P’
n Tree structure suggest recursion at successive hit points
n Recurse forever? No!!
n At each point, only fraction of impinging reflected or refracted ray is lost
n Who determines fraction? Designer… sets transparency or reflectivity in SDL file.
n E.g reflectivity 0.8 means only 80% of impinging ray is reflected
n Thus, need to check reflected contribution by saying
if (reflectivity > 0.6)…
n Also check if(transparency > threshold)
n Basically, do not want to work hard for tiny contributions. Drop (terminate shade) if contribution is too small
n May also need to determine how many times you want to bounce (even if threshold is still high) n For example, in room with many mirrors, do you want to bounce forever (your system may cry!!) n Set recurseLevel (yup!! same as in shadows) to say how many bounces using (variable maxRecursionLevel ) n recurseLevel of 4 or 5 is usually enough to create realistic pictures n Ray from eye to first hit point has recurseLevel of 0 n All rays from first hit point have recurseLevel = 1 n Need to modify shade function to handle recursion
if (hit object is shiny enough) // add reflected light { get reflection direction build reflected ray, refl refl.recurseLevel = r.recurseLevel + 1; color.add(shininess * shade(refl)); } if( hit object is transparent enough) { get transmitted direction build transmitted ray, trans trans.recurseLevel = r.recurseLevel + 1; color.add(transparency * shade(trans)); } return color; }
n So far, found reflected direction ray direction as mirror direction from eye n Transmitted direction obeys Snell’s law n Snell’s law: relationship holds in the following diagram
Ph
m
t
1
1 2
faster
slower θ 2
θ 1
c 1 , c 2 are speeds of light in medium 1 and 2
n There exists transmitted angle at which ray in faster medium (e.g. air) is bent along object surface n That angle ( θ 2 in figure below) is known as the critical angle n Increasing transmission angle beyond critical angle has “no effect”… transmitted ray still below object surface n Physical significance: n Underwater in pond, can see enter world through small cone of angles
Ph
m
t
faster
slower θ 2
θ 1
n Vector for transmission angle can be found as
Ph
m
t
1
2 1
Medium #
Medium # θ 2
θ 1
where dir
c
2 1
2
n Hill, chapter 12