Docsity

Simple Transparency - Advanced Topics in Computer Graphics - Lecture Slides, Slides of Computer Graphics

Partial preview of the text

Download Simple Transparency - Advanced Topics in Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!

Advanced Topics in

Computer Graphics

Chapter 27 – Simple Transparency

Presentation Outline:

ƒ^ Definition and physics of refraction ƒ^ Total Internal Reflection ƒ^ Illumination model ƒ^ Implementation ƒ^ Analysis of transparency using transparent spheres(Disclaimer: all unreferenced figures have been shamelessly stolen from the textbook).

Refraction

ƒ^ Speed of light in a perfect vacuum:

c = 2.99x

7 m/s.

ƒ^ Speed of light is slower when traveling through other media becauseof interaction with the medium’s molecules. ƒ^ The denser the medium, the slower the speed.

Speed of light in non-

vacuum = v. ƒ Absolute index of refraction:

 = c/v

ƒ^ Vacuum:

ƒ^ Air:

ƒ^ Water:

ƒ^ Diamond:

http://www.school-for-champions.com/Science/images/waveobstacle-refraction.gif

Refraction

ƒ^ Objective: Calculate the transmitted ray t ƒ^ Snell’s law (aka law of refraction):

ω: incident rayo r: reflected rayt: transmitted rayi^

: angle of incidence

t^

: angle of refraction

Total Internal Reflection

ƒ^ Total internal reflection may occur when the incident ray isbeing cast from inside the medium with the larger ior. ƒ^ This is because the transmitted ray bends away from thenormal (since <1).

ƒ Note:

normal is

flipped when castingfrom inside, therefore: ƒWhen

c^

(critical

angle) is reached,

t

has no energy, and

r

has all the energy. ƒ Condition

: if term

inside sqrt is negative,we have total internalreflection.

Docsity.com

Illumination Model

ƒ^ Exitant radiance at a point

p :

Illumination Model

ƒ^ The BTDF can be written as follows: ƒ^ Using: We get: Where:

Illumination Model

ƒ^ Remember:

t^

: ior of transmitted radiance sidei: ior of incident radiance side

In the expression

, it is easy to get these terms

flipped because radiance direction is oppositeray direction:

Practical Issues

ƒ^ This can be represented as a binary tree: ƒ^ Do you see a potential problem?

Implementation

ƒ^ Note: Since ior of air is 1 (or very close to 1), and the relativeindex of refraction is

is used in the code.in

ƒPerfectTransmitter:: tir determines if tir exists. ƒPerfectTransmitter:: sample_f calculates the transmitted raywt, and returns the RGB color value scaling factors (since coloris not part of simple transparency)

Implementation

//^ this

computes

the^

direction

wt^ for

perfect

transmission

//^ and

returns

the^

transmission

coefficient

//^ this

is^ only

called

when

there

is^ no

total

internal

reflection

RGBColorPerfectTransmitter::sample_f(const

ShadeRec&

sr,^

const

Vector3D&

wo,^

Vector3D&

wt)^ const

Normal

n(sr.normal); float

cos_thetai

=^ n^

*^ wo;

float

eta^

=^ ior; if^ (cos_thetai

<^ 0.0)

{^

//^ transmitted

ray^

is^ outside

cos_thetai

=^ -cos_thetai; n^ =^ -n;

//^ reverse

direction

of^ normal

eta^ =

1.^

/^ eta;

//^ invert

ior

} float

temp

=^ 1.

-^ (1.

-^ cos_thetai

*^ cos_thetai)

/^ (eta

*^ eta);

float

cos_theta

=^ sqrt(temp);

wt^ =^

-wo^ /

eta^

-^ (cos_theta -^ cos_thetai

/^ eta)

*^ n;

return

(kt^

/^ (eta

*^ eta)

*^ white

/^ fabs(sr.normal

*^ wt));

Implementation

ƒ^ The material Transparent inherits from Phong, togive a reflective highlight to the transparent object(allows us to see that it

exists in certain cases).

ƒ^ Uses 1 BRDF for reflection, 1 BTDF for refraction,and 3 BRDF’s inherited from Phong. ƒ^ Transparent::shade calculates the radiance by usingthe radiance equations discussed previously.

ƒ^ It first checks if tir exists: increments radiance by1xRadiance of reflected ray (because refracted ray is gone,so kr=1.0 and kt=0.0). ƒ^ If no tir: gets wi from BRDF sample_f, gets wo from BTDFsample_f, and uses radiance equation to calculate radiance.

Analysis Using Spheres

ƒ^ Because of their simplicity, spheres allow usto test our transparency rather intuitively. ƒ^ When a sphere’s ior is larger than that of itssurrounding medium (i.e. >=1) , tir can’toccur because of the condition:

b >

,

b^ Є

[0,1]

Analysis Using Spheres

ƒ^ To test if refraction is working properly, let  =1: Transparent*

glass_ptr

=^ new

Transparent;

glass_ptr->set_ks(0.2);glass_ptr->set_exp(2000.0);glass_ptr->set_ior(1.0);glass_ptr->set_kr(0.1);glass_ptr->set_kt(0.9);int num_samples

=^ 16;

vp.set_hres(600);vp.set_vres(600);vp.set_samples(num_samples);vp.set_max_depth(5);