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

Comparing ray/src/rt/m_brdf.c (file contents):
Revision 2.15 by greg, Sat Feb 22 02:07:28 2003 UTC vs.
Revision 2.20 by greg, Thu Aug 28 03:22:16 2003 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   *  Shading for materials with arbitrary BRDF's
6   */
7  
8 < /* ====================================================================
9 < * The Radiance Software License, Version 1.0
10 < *
11 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
12 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
13 < *
14 < * Redistribution and use in source and binary forms, with or without
15 < * modification, are permitted provided that the following conditions
16 < * are met:
17 < *
18 < * 1. Redistributions of source code must retain the above copyright
19 < *         notice, this list of conditions and the following disclaimer.
20 < *
21 < * 2. Redistributions in binary form must reproduce the above copyright
22 < *       notice, this list of conditions and the following disclaimer in
23 < *       the documentation and/or other materials provided with the
24 < *       distribution.
25 < *
26 < * 3. The end-user documentation included with the redistribution,
27 < *           if any, must include the following acknowledgment:
28 < *             "This product includes Radiance software
29 < *                 (http://radsite.lbl.gov/)
30 < *                 developed by the Lawrence Berkeley National Laboratory
31 < *               (http://www.lbl.gov/)."
32 < *       Alternately, this acknowledgment may appear in the software itself,
33 < *       if and wherever such third-party acknowledgments normally appear.
34 < *
35 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
36 < *       and "The Regents of the University of California" must
37 < *       not be used to endorse or promote products derived from this
38 < *       software without prior written permission. For written
39 < *       permission, please contact [email protected].
40 < *
41 < * 5. Products derived from this software may not be called "Radiance",
42 < *       nor may "Radiance" appear in their name, without prior written
43 < *       permission of Lawrence Berkeley National Laboratory.
44 < *
45 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
46 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
49 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
52 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
55 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 < * SUCH DAMAGE.
57 < * ====================================================================
58 < *
59 < * This software consists of voluntary contributions made by many
60 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
61 < * information on Lawrence Berkeley National Laboratory, please see
62 < * <http://www.lbl.gov/>.
63 < */
8 > #include "copyright.h"
9  
10   #include  "ray.h"
11  
12 + #include  "ambient.h"
13 +
14   #include  "data.h"
15  
16   #include  "otypes.h"
# Line 215 | Line 162 | double  omega;                 /* light source size */
162                  dtmp = funvalue(sa[0], 5, vldx);
163                  setcolor(ctmp, dtmp, dtmp, dtmp);
164          }
165 <        if (errno) {
165 >        if (errno == EDOM || errno == ERANGE) {
166                  objerror(np->mp, WARNING, "compute error");
167                  return;
168          }
# Line 225 | Line 172 | double  omega;                 /* light source size */
172                  /*
173                   *  Compute reflected non-diffuse component.
174                   */
175 <                if (np->mp->otype == MAT_MFUNC | np->mp->otype == MAT_MDATA)
175 >                if ((np->mp->otype == MAT_MFUNC) | (np->mp->otype == MAT_MDATA))
176                          multcolor(ctmp, np->mcolor);
177                  dtmp = ldot * omega * np->rspec;
178                  scalecolor(ctmp, dtmp);
# Line 234 | Line 181 | double  omega;                 /* light source size */
181                  /*
182                   *  Compute transmitted non-diffuse component.
183                   */
184 <                if (np->mp->otype == MAT_TFUNC | np->mp->otype == MAT_TDATA)
184 >                if ((np->mp->otype == MAT_TFUNC) | (np->mp->otype == MAT_TDATA))
185                          multcolor(ctmp, np->mcolor);
186                  dtmp = -ldot * omega * np->tspec;
187                  scalecolor(ctmp, dtmp);
# Line 259 | Line 206 | register RAY  *r;
206          register MFUNC  *mf;
207          register int  i;
208                                                  /* check arguments */
209 <        if (m->oargs.nsargs < 10 | m->oargs.nfargs < 9)
209 >        if ((m->oargs.nsargs < 10) | (m->oargs.nfargs < 9))
210                  objerror(m, USER, "bad # arguments");
211          nd.mp = m;
212          nd.pr = r;
# Line 279 | Line 226 | register RAY  *r;
226          setcolor(nd.tdiff, m->oargs.farg[6],
227                          m->oargs.farg[7],
228                          m->oargs.farg[8]);
229 <                                        /* get modifiers */
229 >                                                /* get modifiers */
230          raytexture(r, m->omod);
231          nd.pdot = raynormal(nd.pnorm, r);       /* perturb normal */
232          if (r->rod < 0.0) {                     /* orient perturbed values */
# Line 306 | Line 253 | register RAY  *r;
253          setcolor(ctmp, evalue(mf->ep[3]),
254                          evalue(mf->ep[4]),
255                          evalue(mf->ep[5]));
256 <        if (errno)
256 >        if (errno == EDOM || errno == ERANGE)
257                  objerror(m, WARNING, "compute error");
258          else if (rayorigin(&sr, r, TRANS, bright(ctmp)) == 0) {
259                  if (!(r->crtype & SHADOW) &&
# Line 335 | Line 282 | register RAY  *r;
282          setcolor(ctmp, evalue(mf->ep[0]),
283                          evalue(mf->ep[1]),
284                          evalue(mf->ep[2]));
285 <        if (errno)
285 >        if (errno == EDOM || errno == ERANGE)
286                  objerror(m, WARNING, "compute error");
287          else if (rayorigin(&sr, r, REFLECTED, bright(ctmp)) == 0) {
288                  for (i = 0; i < 3; i++)
# Line 390 | Line 337 | register RAY  *r;
337          if (r->crtype & SHADOW)
338                  return(1);
339                                                  /* check arguments */
340 <        if (m->oargs.nsargs < (hasdata(m->otype)?4:2) | m->oargs.nfargs <
341 <                        (m->otype==MAT_TFUNC|m->otype==MAT_TDATA?6:4))
340 >        if ((m->oargs.nsargs < (hasdata(m->otype)?4:2)) | (m->oargs.nfargs <
341 >                        ((m->otype==MAT_TFUNC)|(m->otype==MAT_TDATA)?6:4)))
342                  objerror(m, USER, "bad # arguments");
343 +                                                /* check for back side */
344 +        if (r->rod < 0.0) {
345 +                if (!backvis && m->otype != MAT_TFUNC
346 +                                && m->otype != MAT_TDATA) {
347 +                        raytrans(r);
348 +                        return(1);
349 +                }
350 +                raytexture(r, m->omod);
351 +                flipsurface(r);                 /* reorient if backvis */
352 +        } else
353 +                raytexture(r, m->omod);
354 +
355          nd.mp = m;
356          nd.pr = r;
357                                                  /* get material color */
# Line 402 | Line 361 | register RAY  *r;
361                                                  /* get specular component */
362          nd.rspec = m->oargs.farg[3];
363                                                  /* compute transmittance */
364 <        if (m->otype == MAT_TFUNC | m->otype == MAT_TDATA) {
364 >        if ((m->otype == MAT_TFUNC) | (m->otype == MAT_TDATA)) {
365                  nd.trans = m->oargs.farg[4]*(1.0 - nd.rspec);
366                  nd.tspec = nd.trans * m->oargs.farg[5];
367                  dtmp = nd.trans - nd.tspec;
# Line 414 | Line 373 | register RAY  *r;
373                                                  /* compute reflectance */
374          dtmp = 1.0 - nd.trans - nd.rspec;
375          setcolor(nd.rdiff, dtmp, dtmp, dtmp);
417                                                /* check for back side */
418        if (r->rod < 0.0) {
419                if (!backvis && m->otype != MAT_TFUNC
420                                && m->otype != MAT_TDATA) {
421                        raytrans(r);
422                        return(1);
423                }
424                flipsurface(r);                 /* reorient if backvis */
425        }
426                                                /* get modifiers */
427        raytexture(r, m->omod);
376          nd.pdot = raynormal(nd.pnorm, r);       /* perturb normal */
377          multcolor(nd.mcolor, r->pcol);          /* modify material color */
378          multcolor(nd.rdiff, nd.mcolor);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines