ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/m_mist.c
(Generate patch)

Comparing ray/src/rt/m_mist.c (file contents):
Revision 2.3 by greg, Mon Dec 11 11:19:33 1995 UTC vs.
Revision 2.9 by gregl, Wed May 28 14:38:32 1997 UTC

# Line 33 | Line 33 | static char SCCSid[] = "$SunId$ LBL";
33   *
34   *  Up to five real arguments may be given for MAT_MIST:
35   *
36 < *      [ext_r  ext_g  ext_b  [albedo [gecc]]]
36 > *      [ext_r  ext_g  ext_b  [albedo_r albedo_g albedo_b [gecc]]]
37   *
38   *  The primaries indicate medium extinction per unit length (absorption
39 < *  plus scattering).  The albedo is the ratio of scattering to extinction,
39 > *  plus scattering), which is added to the global extinction coefficient, set
40 > *  by the -me option.  The albedo is the ratio of scattering to extinction,
41   *  and is set globally by the -ma option (salbedo) and overridden here.
42   *  The Heyney-Greenstein eccentricity parameter (-mg seccg) indicates how much
43   *  scattering favors the forward direction.  A value of 0 means isotropic
44   *  scattering.  A value approaching 1 indicates strong forward scattering.
45   */
46  
47 + #ifndef  MAXSLIST
48 + #define  MAXSLIST       32      /* maximum sources to check */
49 + #endif
50 +
51   #define RELAYDELIM      '>'             /* relay delimiter character */
52  
53   extern COLOR  cextinction;              /* global coefficient of extinction */
54 < extern double  salbedo;                 /* global scattering albedo */
54 > extern COLOR  salbedo;                  /* global scattering albedo */
55   extern double  seccg;                   /* global scattering eccentricity */
56  
57  
# Line 101 | Line 106 | register int  *sl;
106          for (i = sl[0]; i > 0; i--)
107                  if (!inslist(r->slights, sl[i])) {
108                          if (r->slights[0] >= MAXSLIST)
109 <                                error(USER, "scattering source list overflow");
109 >                                error(INTERNAL,
110 >                                        "scattering source list overflow");
111                          r->slights[++r->slights[0]] = sl[i];
112                  }
113   }
# Line 118 | Line 124 | register RAY  *r;
124          double  re, ge, be;
125          register int  i, j;
126                                          /* check arguments */
127 <        if (m->oargs.nfargs > 5)
127 >        if (m->oargs.nfargs > 7)
128                  objerror(m, USER, "bad arguments");
129                                          /* get source indices */
130 <        if (!(r->crtype & SHADOW) && m->oargs.nsargs > 0 &&
125 <                        (myslist = (int *)m->os) == NULL) {
130 >        if (m->oargs.nsargs > 0 && (myslist = (int *)m->os) == NULL) {
131                  if (m->oargs.nsargs > MAXSLIST)
132 <                        objerror(m, USER, "too many sources in list");
132 >                        objerror(m, INTERNAL, "too many sources in list");
133                  myslist = (int *)malloc((m->oargs.nsargs+1)*sizeof(int));
134                  if (myslist == NULL)
135                          goto memerr;
# Line 166 | Line 171 | register RAY  *r;
171                  p.slights[0] = 0;
172          if (r->rod > 0.) {                      /* entering ray */
173                  addcolor(p.cext, mext);
174 <                if (m->oargs.nfargs > 3)
175 <                        p.albedo = m->oargs.farg[3];
176 <                if (m->oargs.nfargs > 4)
177 <                        p.gecc = m->oargs.farg[4];
174 >                if (m->oargs.nfargs > 5)
175 >                        setcolor(p.albedo, m->oargs.farg[3],
176 >                                        m->oargs.farg[4], m->oargs.farg[5]);
177 >                if (m->oargs.nfargs > 6)
178 >                        p.gecc = m->oargs.farg[6];
179                  add2slist(&p, myslist);                 /* add to list */
180          } else {                                /* leaving ray */
181                  if (myslist != NULL) {                  /* delete from list */
# Line 181 | Line 187 | register RAY  *r;
187                                          p.slights[++i] = p.slights[j];
188                          if (p.slights[0] - i < myslist[0]) {    /* fix old */
189                                  addcolor(r->cext, mext);
190 <                                if (m->oargs.nfargs > 3)
191 <                                        r->albedo = m->oargs.farg[3];
192 <                                if (m->oargs.nfargs > 4)
193 <                                        r->gecc = m->oargs.farg[4];
190 >                                if (m->oargs.nfargs > 5)
191 >                                        setcolor(r->albedo, m->oargs.farg[3],
192 >                                        m->oargs.farg[4], m->oargs.farg[5]);
193 >                                if (m->oargs.nfargs > 6)
194 >                                        r->gecc = m->oargs.farg[6];
195                                  add2slist(r, myslist);
196                          }
197                          p.slights[0] = i;
198                  }
199 <                re = colval(r->cext,RED) - colval(mext,RED);
200 <                ge = colval(r->cext,GRN) - colval(mext,GRN);
201 <                be = colval(r->cext,BLU) - colval(mext,BLU);
202 <                setcolor(p.cext, re<0. ? 0. : re,
203 <                                ge<0. ? 0. : ge,
204 <                                be<0. ? 0. : be);
205 <                if (m->oargs.nfargs > 3)
206 <                        p.albedo = salbedo;
207 <                if (m->oargs.nfargs > 4)
199 >                if ((re = colval(r->cext,RED) - colval(mext,RED)) <
200 >                                colval(cextinction,RED))
201 >                        re = colval(cextinction,RED);
202 >                if ((ge = colval(r->cext,GRN) - colval(mext,GRN)) <
203 >                                colval(cextinction,GRN))
204 >                        ge = colval(cextinction,GRN);
205 >                if ((be = colval(r->cext,BLU) - colval(mext,BLU)) <
206 >                                colval(cextinction,BLU))
207 >                        be = colval(cextinction,BLU);
208 >                setcolor(p.cext, re, ge, be);
209 >                if (m->oargs.nfargs > 5)
210 >                        copycolor(p.albedo, salbedo);
211 >                if (m->oargs.nfargs > 6)
212                          p.gecc = seccg;
213          }
214          rayvalue(&p);                           /* calls rayparticipate() */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines