
170 5. Realistic visualization
DoRay( p,
ˆ
d, s ) {
Find the identity of the po lyg o n , k, that intersects the ray p + µ
ˆ
d
at p
i
and is closest to p.
Calculate surface color s
s
for polygon k at p
i
ˆ
d
t
use procedural texture or image map if required
If the material properties of k indicate that it is partially
reflective or transparent th en cast extra rays .
If reflective get reflective direction
ˆ
d
r
DoRay( p
i
,
ˆ
d
r
, s
r
) ;
If transparent get transparent direction
ˆ
d
t
DoRay( p
i
,
ˆ
d
t
, s
t
)
Get surface nor ma l, ˆn
i
at p
i
, use Phong’s interpolation
and any proced u r a l or bump mapping if necessary.
From p
i
send feeler ray to each light sou r c e. Test every po lyg o n