--- ray/src/rt/m_mist.c 1995/12/09 09:40:42 2.2 +++ ray/src/rt/m_mist.c 1996/04/17 14:10:23 2.6 @@ -33,10 +33,11 @@ static char SCCSid[] = "$SunId$ LBL"; * * Up to five real arguments may be given for MAT_MIST: * - * [ext_r ext_g ext_b [albedo [gecc]]] + * [ext_r ext_g ext_b [albedo_r albedo_g albedo_b [gecc]]] * * The primaries indicate medium extinction per unit length (absorption - * plus scattering). The albedo is the ratio of scattering to extinction, + * plus scattering), which is added to the global extinction coefficient, set + * by the -me option. The albedo is the ratio of scattering to extinction, * and is set globally by the -ma option (salbedo) and overridden here. * The Heyney-Greenstein eccentricity parameter (-mg seccg) indicates how much * scattering favors the forward direction. A value of 0 means isotropic @@ -46,7 +47,7 @@ static char SCCSid[] = "$SunId$ LBL"; #define RELAYDELIM '>' /* relay delimiter character */ extern COLOR cextinction; /* global coefficient of extinction */ -extern double salbedo; /* global scattering albedo */ +extern COLOR salbedo; /* global scattering albedo */ extern double seccg; /* global scattering eccentricity */ @@ -165,10 +166,11 @@ register RAY *r; p.slights[0] = 0; if (r->rod > 0.) { /* entering ray */ addcolor(p.cext, mext); - if (m->oargs.nfargs > 3) - p.albedo = m->oargs.farg[3]; - if (m->oargs.nfargs > 4) - p.gecc = m->oargs.farg[4]; + if (m->oargs.nfargs > 5) + setcolor(p.albedo, m->oargs.farg[3], + m->oargs.farg[4], m->oargs.farg[5]); + if (m->oargs.nfargs > 6) + p.gecc = m->oargs.farg[6]; add2slist(&p, myslist); /* add to list */ } else { /* leaving ray */ if (myslist != NULL) { /* delete from list */ @@ -180,23 +182,28 @@ register RAY *r; p.slights[++i] = p.slights[j]; if (p.slights[0] - i < myslist[0]) { /* fix old */ addcolor(r->cext, mext); - if (m->oargs.nfargs > 3) - r->albedo = m->oargs.farg[3]; - if (m->oargs.nfargs > 4) - r->gecc = m->oargs.farg[4]; + if (m->oargs.nfargs > 5) + setcolor(r->albedo, m->oargs.farg[3], + m->oargs.farg[4], m->oargs.farg[5]); + if (m->oargs.nfargs > 6) + r->gecc = m->oargs.farg[6]; add2slist(r, myslist); } p.slights[0] = i; } - re = colval(r->cext,RED) - colval(mext,RED); - ge = colval(r->cext,GRN) - colval(mext,GRN); - be = colval(r->cext,BLU) - colval(mext,BLU); - setcolor(p.cext, re<0. ? 0. : re, - ge<0. ? 0. : ge, - be<0. ? 0. : be); - if (m->oargs.nfargs > 3) - p.albedo = salbedo; - if (m->oargs.nfargs > 4) + if ((re = colval(r->cext,RED) - colval(mext,RED)) < + colval(cextinction,RED)) + re = colval(cextinction,RED); + if ((ge = colval(r->cext,GRN) - colval(mext,GRN)) < + colval(cextinction,GRN)) + ge = colval(cextinction,GRN); + if ((be = colval(r->cext,BLU) - colval(mext,BLU)) < + colval(cextinction,BLU)) + be = colval(cextinction,BLU); + setcolor(p.cext, re, ge, be); + if (m->oargs.nfargs > 5) + copycolor(p.albedo, salbedo); + if (m->oargs.nfargs > 6) p.gecc = seccg; } rayvalue(&p); /* calls rayparticipate() */