--- ray/src/rt/aniso.c 2003/02/25 02:47:22 2.35 +++ ray/src/rt/aniso.c 2003/03/12 04:59:05 2.38 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: aniso.c,v 2.35 2003/02/25 02:47:22 greg Exp $"; +static const char RCSid[] = "$Id: aniso.c,v 2.38 2003/03/12 04:59:05 greg Exp $"; #endif /* * Shading functions for anisotropic materials. @@ -192,9 +192,19 @@ register RAY *r; if (m->oargs.nfargs != (m->otype == MAT_TRANS2 ? 8 : 6)) objerror(m, USER, "bad number of real arguments"); + /* check for back side */ + if (r->rod < 0.0) { + if (!backvis && m->otype != MAT_TRANS2) { + raytrans(r); + return(1); + } + raytexture(r, m->omod); + flipsurface(r); /* reorient if backvis */ + } else + raytexture(r, m->omod); + /* get material color */ nd.mp = m; nd.rp = r; - /* get material color */ setcolor(nd.mcolor, m->oargs.farg[0], m->oargs.farg[1], m->oargs.farg[2]); @@ -204,16 +214,7 @@ register RAY *r; nd.v_alpha = m->oargs.farg[5]; if (nd.u_alpha < FTINY || nd.v_alpha <= FTINY) objerror(m, USER, "roughness too small"); - /* check for back side */ - if (r->rod < 0.0) { - if (!backvis && m->otype != MAT_TRANS2) { - raytrans(r); - return(1); - } - flipsurface(r); /* reorient if backvis */ - } - /* get modifiers */ - raytexture(r, m->omod); + nd.pdot = raynormal(nd.pnorm, r); /* perturb normal */ if (nd.pdot < .001) nd.pdot = .001; /* non-zero for diraniso() */ @@ -264,7 +265,8 @@ register RAY *r; /* diffuse reflection */ nd.rdiff = 1.0 - nd.trans - nd.rspec; - if (r->ro != NULL && isflat(r->ro->otype)) + if (r->ro != NULL && isflat(r->ro->otype) && + DOT(r->pert,r->pert) <= FTINY*FTINY) nd.specfl |= SP_FLAT; getacoords(r, &nd); /* set up coordinates */ @@ -317,7 +319,7 @@ register ANISODAT *np; errno = 0; for (i = 0; i < 3; i++) np->u[i] = evalue(mf->ep[i]); - if (errno) { + if (errno == EDOM || errno == ERANGE) { objerror(np->mp, WARNING, "compute error"); np->specfl |= SP_BADU; return;