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

Comparing ray/src/rt/aniso.c (file contents):
Revision 2.7 by greg, Wed Jan 15 16:59:55 1992 UTC vs.
Revision 2.11 by greg, Tue Mar 3 16:20:00 1992 UTC

# Line 39 | Line 39 | extern double  specjitter;             /* specular sampling jitte
39                                  /* specularity flags */
40   #define  SP_REFL        01              /* has reflected specular component */
41   #define  SP_TRAN        02              /* has transmitted specular */
42 < #define  SP_PURE        010             /* purely specular (zero roughness) */
43 < #define  SP_FLAT        020             /* reflecting surface is flat */
44 < #define  SP_RBLT        040             /* reflection below sample threshold */
45 < #define  SP_TBLT        0100            /* transmission below threshold */
46 < #define  SP_BADU        0200            /* bad u direction calculation */
42 > #define  SP_FLAT        04              /* reflecting surface is flat */
43 > #define  SP_RBLT        010             /* reflection below sample threshold */
44 > #define  SP_TBLT        020             /* transmission below threshold */
45 > #define  SP_BADU        040             /* bad u direction calculation */
46  
47   typedef struct {
48          OBJREC  *mp;            /* material pointer */
# Line 94 | Line 93 | double  omega;                 /* light source size */
93                  scalecolor(ctmp, dtmp);
94                  addcolor(cval, ctmp);
95          }
96 <        if (ldot > FTINY && (np->specfl&(SP_REFL|SP_PURE|SP_BADU)) == SP_REFL) {
96 >        if (ldot > FTINY && (np->specfl&(SP_REFL|SP_BADU)) == SP_REFL) {
97                  /*
98                   *  Compute specular reflection coefficient using
99                   *  anisotropic gaussian distribution model.
# Line 136 | Line 135 | double  omega;                 /* light source size */
135                  scalecolor(ctmp, dtmp);
136                  addcolor(cval, ctmp);
137          }
138 <        if (ldot < -FTINY && (np->specfl&(SP_TRAN|SP_PURE|SP_BADU)) == SP_TRAN) {
138 >        if (ldot < -FTINY && (np->specfl&(SP_TRAN|SP_BADU)) == SP_TRAN) {
139                  /*
140                   *  Compute specular transmission.  Specular transmission
141                   *  is always modified by material color.
# Line 160 | Line 159 | register OBJREC  *m;
159   register RAY  *r;
160   {
161          ANISODAT  nd;
163        double  transtest, transdist;
162          double  dtmp;
163          COLOR  ctmp;
164          register int  i;
165                                                  /* easy shadow test */
166 <        if (r->crtype & SHADOW && m->otype != MAT_TRANS2)
166 >        if (r->crtype & SHADOW)
167                  return;
168  
169          if (m->oargs.nfargs != (m->otype == MAT_TRANS2 ? 8 : 6))
# Line 180 | Line 178 | register RAY  *r;
178          nd.specfl = 0;
179          nd.u_alpha = m->oargs.farg[4];
180          nd.v_alpha = m->oargs.farg[5];
181 <        if (nd.u_alpha <= FTINY || nd.v_alpha <= FTINY)
182 <                nd.specfl |= SP_PURE;
181 >        if (nd.u_alpha < 1e-6 || nd.v_alpha <= 1e-6)
182 >                objerror(m, USER, "roughness too small");
183                                                  /* reorient if necessary */
184          if (r->rod < 0.0)
185                  flipsurface(r);
# Line 191 | Line 189 | register RAY  *r;
189          if (nd.pdot < .001)
190                  nd.pdot = .001;                 /* non-zero for diraniso() */
191          multcolor(nd.mcolor, r->pcol);          /* modify material color */
194        transtest = 0;
192                                                  /* get specular component */
193          if ((nd.rspec = m->oargs.farg[3]) > FTINY) {
194                  nd.specfl |= SP_REFL;
# Line 209 | Line 206 | register RAY  *r;
206                                                  /* check threshold */
207                  if (specthresh > FTINY &&
208                                  ((specthresh >= 1.-FTINY ||
209 <                                specthresh + (.1 - .2*urand(8199+samplendx))
213 <                                        > nd.rspec)))
209 >                                specthresh + (.05 - .1*frandom()) > nd.rspec)))
210                          nd.specfl |= SP_RBLT;
211                                                  /* compute refl. direction */
212                  for (i = 0; i < 3; i++)
# Line 218 | Line 214 | register RAY  *r;
214                  if (DOT(nd.vrefl, r->ron) <= FTINY)     /* penetration? */
215                          for (i = 0; i < 3; i++)         /* safety measure */
216                                  nd.vrefl[i] = r->rdir[i] + 2.*r->rod*r->ron[i];
221
222                if (!(r->crtype & SHADOW) && nd.specfl & SP_PURE) {
223                        RAY  lr;
224                        if (rayorigin(&lr, r, REFLECTED, nd.rspec) == 0) {
225                                VCOPY(lr.rdir, nd.vrefl);
226                                rayvalue(&lr);
227                                multcolor(lr.rcol, nd.scolor);
228                                addcolor(r->rcol, lr.rcol);
229                        }
230                }
217          }
218                                                  /* compute transmission */
219          if (m->otype == MAT_TRANS) {
# Line 240 | Line 226 | register RAY  *r;
226                          if (specthresh > FTINY &&
227                                          ((specthresh >= 1.-FTINY ||
228                                          specthresh +
229 <                                            (.1 - .2*urand(7241+samplendx))
244 <                                                > nd.tspec)))
229 >                                            (.05 - .1*frandom()) > nd.tspec)))
230                                  nd.specfl |= SP_TBLT;
231 <                        if (r->crtype & SHADOW ||
247 <                                        DOT(r->pert,r->pert) <= FTINY*FTINY) {
231 >                        if (DOT(r->pert,r->pert) <= FTINY*FTINY) {
232                                  VCOPY(nd.prdir, r->rdir);
249                                transtest = 2;
233                          } else {
234                                  for (i = 0; i < 3; i++)         /* perturb */
235                                          nd.prdir[i] = r->rdir[i] -
# Line 259 | Line 242 | register RAY  *r;
242                  }
243          } else
244                  nd.tdiff = nd.tspec = nd.trans = 0.0;
262                                                /* transmitted ray */
263        if ((nd.specfl&(SP_TRAN|SP_PURE)) == (SP_TRAN|SP_PURE)) {
264                RAY  lr;
265                if (rayorigin(&lr, r, TRANS, nd.tspec) == 0) {
266                        VCOPY(lr.rdir, nd.prdir);
267                        rayvalue(&lr);
268                        scalecolor(lr.rcol, nd.tspec);
269                        multcolor(lr.rcol, nd.mcolor);  /* modified by color */
270                        addcolor(r->rcol, lr.rcol);
271                        transtest *= bright(lr.rcol);
272                        transdist = r->rot + lr.rt;
273                }
274        }
245  
276        if (r->crtype & SHADOW)                 /* the rest is shadow */
277                return;
246                                                  /* diffuse reflection */
247          nd.rdiff = 1.0 - nd.trans - nd.rspec;
248  
249 <        if (nd.specfl & SP_PURE && nd.rdiff <= FTINY && nd.tdiff <= FTINY)
250 <                return;                         /* 100% pure specular */
283 <
284 <        if (r->ro->otype == OBJ_FACE || r->ro->otype == OBJ_RING)
249 >        if (r->ro != NULL && (r->ro->otype == OBJ_FACE ||
250 >                        r->ro->otype == OBJ_RING))
251                  nd.specfl |= SP_FLAT;
252  
253          getacoords(r, &nd);                     /* set up coordinates */
254  
255 <        if (nd.specfl & (SP_REFL|SP_TRAN) && !(nd.specfl & (SP_PURE|SP_BADU)))
255 >        if (nd.specfl & (SP_REFL|SP_TRAN) && !(nd.specfl & SP_BADU))
256                  agaussamp(r, &nd);
257  
258          if (nd.rdiff > FTINY) {         /* ambient from this side */
# Line 311 | Line 277 | register RAY  *r;
277          }
278                                          /* add direct component */
279          direct(r, diraniso, &nd);
314                                        /* check distance */
315        if (transtest > bright(r->rcol))
316                r->rt = transdist;
280   }
281  
282  
# Line 412 | Line 375 | register ANISODAT  *np;
375                  else
376                          VCOPY(sr.rdir, np->prdir);      /* else no jitter */
377                  rayvalue(&sr);
378 <                multcolor(sr.rcol, np->scolor);
378 >                scalecolor(sr.rcol, np->tspec);
379 >                multcolor(sr.rcol, np->mcolor);         /* modify by color */
380                  addcolor(r->rcol, sr.rcol);
381                  ndims--;
382          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines