1 |
< |
/* Copyright (c) 1995 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1996 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
27 |
|
extern COLOR ambval; /* ambient value */ |
28 |
|
|
29 |
|
extern COLOR cextinction; /* global extinction coefficient */ |
30 |
< |
extern double salbedo; /* global scattering albedo */ |
30 |
> |
extern COLOR salbedo; /* global scattering albedo */ |
31 |
|
extern double seccg; /* global scattering eccentricity */ |
32 |
|
extern double ssampdist; /* scatter sampling distance */ |
33 |
|
|
62 |
|
r->clipset = NULL; |
63 |
|
r->revf = raytrace; |
64 |
|
copycolor(r->cext, cextinction); |
65 |
< |
r->albedo = salbedo; |
65 |
> |
copycolor(r->albedo, salbedo); |
66 |
|
r->gecc = seccg; |
67 |
|
r->slights = NULL; |
68 |
|
} else { /* spawned ray */ |
79 |
|
} |
80 |
|
r->revf = ro->revf; |
81 |
|
copycolor(r->cext, ro->cext); |
82 |
< |
r->albedo = ro->albedo; |
82 |
> |
copycolor(r->albedo, ro->albedo); |
83 |
|
r->gecc = ro->gecc; |
84 |
|
r->slights = ro->slights; |
85 |
|
r->rweight = ro->rweight * rw; |
189 |
|
register RAY *r; |
190 |
|
{ |
191 |
|
COLOR ce, ca; |
192 |
– |
double dist; |
192 |
|
double re, ge, be; |
193 |
|
|
194 |
|
if (intens(r->cext) <= 1./FHUGE) |
195 |
|
return; /* no medium */ |
196 |
< |
if ((dist = r->rot) >= FHUGE) |
197 |
< |
dist = 2.*thescene.cusize; /* what to use for infinity? */ |
198 |
< |
if (r->crtype & SHADOW) |
199 |
< |
dist *= 1. - salbedo; /* no scattering for sources */ |
200 |
< |
if (dist <= FTINY) |
201 |
< |
return; /* no effective ray travel */ |
202 |
< |
re = dist*colval(r->cext,RED); |
203 |
< |
ge = dist*colval(r->cext,GRN); |
204 |
< |
be = dist*colval(r->cext,BLU); |
205 |
< |
setcolor(ce, re>92. ? 0. : exp(-re), |
206 |
< |
ge>92. ? 0. : exp(-ge), |
208 |
< |
be>92. ? 0. : exp(-be)); |
196 |
> |
re = r->rot*colval(r->cext,RED); |
197 |
> |
ge = r->rot*colval(r->cext,GRN); |
198 |
> |
be = r->rot*colval(r->cext,BLU); |
199 |
> |
if (r->crtype & SHADOW) { /* no scattering for sources */ |
200 |
> |
re *= 1. - colval(r->albedo,RED); |
201 |
> |
ge *= 1. - colval(r->albedo,GRN); |
202 |
> |
be *= 1. - colval(r->albedo,BLU); |
203 |
> |
} |
204 |
> |
setcolor(ce, re<=0. ? 1. : re>92. ? 0. : exp(-re), |
205 |
> |
ge<=0. ? 1. : ge>92. ? 0. : exp(-ge), |
206 |
> |
be<=0. ? 1. : be>92. ? 0. : exp(-be)); |
207 |
|
multcolor(r->rcol, ce); /* path absorption */ |
208 |
< |
if (r->albedo <= FTINY || r->crtype & SHADOW) |
208 |
> |
if (r->crtype & SHADOW || intens(r->albedo) <= FTINY) |
209 |
|
return; /* no scattering */ |
210 |
< |
setcolor(ca, salbedo*colval(ambval,RED)*(1.-colval(ce,RED)), |
211 |
< |
salbedo*colval(ambval,GRN)*(1.-colval(ce,GRN)), |
212 |
< |
salbedo*colval(ambval,BLU)*(1.-colval(ce,BLU))); |
210 |
> |
setcolor(ca, |
211 |
> |
colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)), |
212 |
> |
colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)), |
213 |
> |
colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU))); |
214 |
|
addcolor(r->rcol, ca); /* ambient in scattering */ |
215 |
|
srcscatter(r); /* source in scattering */ |
216 |
|
} |