
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















Chapter 27 – Simple Transparency
//^ 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
//^ transmitted
ray^
is^ outside
cos_thetai
=^ -cos_thetai; n^ =^ -n;
//^ reverse
direction
of^ normal
eta^ =
/^ eta;
//^ invert
ior
} float
temp
-^ 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));
b >
,
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
vp.set_hres(600);vp.set_vres(600);vp.set_samples(num_samples);vp.set_max_depth(5);