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

Comparing ray/src/rt/normal.c (file contents):
Revision 2.8 by greg, Wed Jan 15 16:59:52 1992 UTC vs.
Revision 2.15 by greg, Wed Apr 22 09:05:30 1992 UTC

# Line 43 | Line 43 | extern double  specjitter;             /* specular sampling jitte
43                                  /* specularity flags */
44   #define  SP_REFL        01              /* has reflected specular component */
45   #define  SP_TRAN        02              /* has transmitted specular */
46 < #define  SP_PURE        010             /* purely specular (zero roughness) */
47 < #define  SP_FLAT        020             /* flat reflecting surface */
48 < #define  SP_RBLT        040             /* reflection below sample threshold */
49 < #define  SP_TBLT        0100            /* transmission below threshold */
46 > #define  SP_PURE        04              /* purely specular (zero roughness) */
47 > #define  SP_FLAT        010             /* flat reflecting surface */
48 > #define  SP_RBLT        020             /* reflection below sample threshold */
49 > #define  SP_TBLT        040             /* transmission below threshold */
50  
51   typedef struct {
52          OBJREC  *mp;            /* material pointer */
# Line 108 | Line 108 | double  omega;                 /* light source size */
108                                                  /* worth using? */
109                  if (dtmp > FTINY) {
110                          copycolor(ctmp, np->scolor);
111 <                        dtmp *= omega / np->pdot;
111 >                        dtmp *= omega * sqrt(ldot/np->pdot);
112                          scalecolor(ctmp, dtmp);
113                          addcolor(cval, ctmp);
114                  }
# Line 134 | Line 134 | double  omega;                 /* light source size */
134                                                  /* worth using? */
135                  if (dtmp > FTINY) {
136                          copycolor(ctmp, np->mcolor);
137 <                        dtmp *= np->tspec * omega / np->pdot;
137 >                        dtmp *= np->tspec * omega * sqrt(ldot/np->pdot);
138                          scalecolor(ctmp, dtmp);
139                          addcolor(cval, ctmp);
140                  }
# Line 192 | Line 192 | register RAY  *r;
192                          colval(nd.scolor,i) += (1.0-colval(nd.scolor,i))*dtmp;
193                  nd.rspec += (1.0-nd.rspec)*dtmp;
194                                                  /* check threshold */
195 <                if (specthresh > FTINY &&
196 <                                ((specthresh >= 1.-FTINY ||
197 <                                specthresh + (.1 - .2*urand(8199+samplendx))
198 <                                        > nd.rspec)))
195 >                if (!(nd.specfl & SP_PURE) &&
196 >                                specthresh > FTINY &&
197 >                                (specthresh >= 1.-FTINY ||
198 >                                specthresh > nd.rspec))
199                          nd.specfl |= SP_RBLT;
200                                                  /* compute reflected ray */
201                  for (i = 0; i < 3; i++)
# Line 222 | Line 222 | register RAY  *r;
222                  if (nd.tspec > FTINY) {
223                          nd.specfl |= SP_TRAN;
224                                                          /* check threshold */
225 <                        if (specthresh > FTINY &&
226 <                                        ((specthresh >= 1.-FTINY ||
227 <                                        specthresh +
228 <                                            (.1 - .2*urand(7241+samplendx))
229 <                                                > nd.tspec)))
225 >                        if (!(nd.specfl & SP_PURE) && specthresh > FTINY &&
226 >                                        (specthresh >= 1.-FTINY ||
227 >                                        specthresh > nd.tspec))
228                                  nd.specfl |= SP_TBLT;
229                          if (r->crtype & SHADOW ||
230                                          DOT(r->pert,r->pert) <= FTINY*FTINY) {
# Line 256 | Line 254 | register RAY  *r;
254                          transtest *= bright(lr.rcol);
255                          transdist = r->rot + lr.rt;
256                  }
257 <        }
257 >        } else
258 >                transtest = 0;
259  
260          if (r->crtype & SHADOW)                 /* the rest is shadow */
261                  return;
# Line 266 | Line 265 | register RAY  *r;
265          if (nd.specfl & SP_PURE && nd.rdiff <= FTINY && nd.tdiff <= FTINY)
266                  return;                         /* 100% pure specular */
267  
268 <        if (r->ro->otype == OBJ_FACE || r->ro->otype == OBJ_RING)
268 >        if (r->ro != NULL && (r->ro->otype == OBJ_FACE ||
269 >                        r->ro->otype == OBJ_RING))
270                  nd.specfl |= SP_FLAT;
271  
272          if (nd.specfl & (SP_REFL|SP_TRAN) && !(nd.specfl & SP_PURE))
# Line 310 | Line 310 | register NORMDAT  *np;
310          double  rv[2];
311          double  d, sinp, cosp;
312          register int  i;
313 +                                        /* quick test */
314 +        if ((np->specfl & (SP_REFL|SP_RBLT)) != SP_REFL &&
315 +                        (np->specfl & (SP_TRAN|SP_TBLT)) != SP_TRAN)
316 +                return;
317                                          /* set up sample coordinates */
318          v[0] = v[1] = v[2] = 0.0;
319          for (i = 0; i < 3; i++)
# Line 366 | Line 370 | register NORMDAT  *np;
370                  else
371                          VCOPY(sr.rdir, np->prdir);      /* else no jitter */
372                  rayvalue(&sr);
373 <                multcolor(sr.rcol, np->scolor);
373 >                scalecolor(sr.rcol, np->tspec);
374 >                multcolor(sr.rcol, np->mcolor);         /* modified by color */
375                  addcolor(r->rcol, sr.rcol);
376                  ndims--;
377          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines