Raytracing: Reflection and Transparency, Slides of Computer Graphics

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

2012/2013

Uploaded on 04/27/2013

astii
astii 🇮🇳

4.3

(15)

111 documents

1 / 16

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Graphics
Raytracing (Part 4)
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Raytracing: Reflection and Transparency and more Slides Computer Graphics in PDF only on Docsity!

Computer Graphics Raytracing (Part 4)

Reflection and Transparency

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

I = Iamb + Idiff + Ispec + Irefl + I tran

Reflection and Transparency

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

r = dir − 2 ( dir • m ) m

Ph

v

r

m

s

dir

t

IR

IT

I

P’

Reflection and Transparency

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’

Reflection and Transparency

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

Refraction and Transparency

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

Recursive shade( ) skeleton

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; }

Finding Transmitted Direction

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

sin( 2 ) sin( )

c c

faster

slower θ 2

θ 1

c 1 , c 2 are speeds of light in medium 1 and 2

Critical Angle

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

Transmission Angle

n Vector for transmission angle can be found as

Ph

m

t

t dir m dir  m

= + ( • )−cos( 2 )

1

2 1

c

c

c

c

Medium #

Medium # θ 2

θ 1

where dir

c

c1 (^ )

2 1

2

cos( 2 ) 1  1 −( m • dir )

c

c

References

n Hill, chapter 12