--- ray/src/rt/normal.c 1992/01/15 16:59:52 2.8 +++ ray/src/rt/normal.c 1992/04/22 09:05:30 2.15 @@ -43,10 +43,10 @@ extern double specjitter; /* specular sampling jitte /* specularity flags */ #define SP_REFL 01 /* has reflected specular component */ #define SP_TRAN 02 /* has transmitted specular */ -#define SP_PURE 010 /* purely specular (zero roughness) */ -#define SP_FLAT 020 /* flat reflecting surface */ -#define SP_RBLT 040 /* reflection below sample threshold */ -#define SP_TBLT 0100 /* transmission below threshold */ +#define SP_PURE 04 /* purely specular (zero roughness) */ +#define SP_FLAT 010 /* flat reflecting surface */ +#define SP_RBLT 020 /* reflection below sample threshold */ +#define SP_TBLT 040 /* transmission below threshold */ typedef struct { OBJREC *mp; /* material pointer */ @@ -108,7 +108,7 @@ double omega; /* light source size */ /* worth using? */ if (dtmp > FTINY) { copycolor(ctmp, np->scolor); - dtmp *= omega / np->pdot; + dtmp *= omega * sqrt(ldot/np->pdot); scalecolor(ctmp, dtmp); addcolor(cval, ctmp); } @@ -134,7 +134,7 @@ double omega; /* light source size */ /* worth using? */ if (dtmp > FTINY) { copycolor(ctmp, np->mcolor); - dtmp *= np->tspec * omega / np->pdot; + dtmp *= np->tspec * omega * sqrt(ldot/np->pdot); scalecolor(ctmp, dtmp); addcolor(cval, ctmp); } @@ -192,10 +192,10 @@ register RAY *r; colval(nd.scolor,i) += (1.0-colval(nd.scolor,i))*dtmp; nd.rspec += (1.0-nd.rspec)*dtmp; /* check threshold */ - if (specthresh > FTINY && - ((specthresh >= 1.-FTINY || - specthresh + (.1 - .2*urand(8199+samplendx)) - > nd.rspec))) + if (!(nd.specfl & SP_PURE) && + specthresh > FTINY && + (specthresh >= 1.-FTINY || + specthresh > nd.rspec)) nd.specfl |= SP_RBLT; /* compute reflected ray */ for (i = 0; i < 3; i++) @@ -222,11 +222,9 @@ register RAY *r; if (nd.tspec > FTINY) { nd.specfl |= SP_TRAN; /* check threshold */ - if (specthresh > FTINY && - ((specthresh >= 1.-FTINY || - specthresh + - (.1 - .2*urand(7241+samplendx)) - > nd.tspec))) + if (!(nd.specfl & SP_PURE) && specthresh > FTINY && + (specthresh >= 1.-FTINY || + specthresh > nd.tspec)) nd.specfl |= SP_TBLT; if (r->crtype & SHADOW || DOT(r->pert,r->pert) <= FTINY*FTINY) { @@ -256,7 +254,8 @@ register RAY *r; transtest *= bright(lr.rcol); transdist = r->rot + lr.rt; } - } + } else + transtest = 0; if (r->crtype & SHADOW) /* the rest is shadow */ return; @@ -266,7 +265,8 @@ register RAY *r; if (nd.specfl & SP_PURE && nd.rdiff <= FTINY && nd.tdiff <= FTINY) return; /* 100% pure specular */ - if (r->ro->otype == OBJ_FACE || r->ro->otype == OBJ_RING) + if (r->ro != NULL && (r->ro->otype == OBJ_FACE || + r->ro->otype == OBJ_RING)) nd.specfl |= SP_FLAT; if (nd.specfl & (SP_REFL|SP_TRAN) && !(nd.specfl & SP_PURE)) @@ -310,6 +310,10 @@ register NORMDAT *np; double rv[2]; double d, sinp, cosp; register int i; + /* quick test */ + if ((np->specfl & (SP_REFL|SP_RBLT)) != SP_REFL && + (np->specfl & (SP_TRAN|SP_TBLT)) != SP_TRAN) + return; /* set up sample coordinates */ v[0] = v[1] = v[2] = 0.0; for (i = 0; i < 3; i++) @@ -366,7 +370,8 @@ register NORMDAT *np; else VCOPY(sr.rdir, np->prdir); /* else no jitter */ rayvalue(&sr); - multcolor(sr.rcol, np->scolor); + scalecolor(sr.rcol, np->tspec); + multcolor(sr.rcol, np->mcolor); /* modified by color */ addcolor(r->rcol, sr.rcol); ndims--; }