--- ray/src/common/bsdf.c 2011/04/08 23:23:28 2.18 +++ ray/src/common/bsdf.c 2011/04/09 15:39:16 2.19 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: bsdf.c,v 2.18 2011/04/08 23:23:28 greg Exp $"; +static const char RCSid[] = "$Id: bsdf.c,v 2.19 2011/04/09 15:39:16 greg Exp $"; #endif /* * bsdf.c @@ -451,7 +451,7 @@ SDmultiSamp(double t[], int n, double randX) bitmask_t ndx, coord[MS_MAXDIM]; while (n > MS_MAXDIM) /* punt for higher dimensions */ - t[--n] = rand()*(1./RAND_MAX); + t[--n] = rand()*(1./(RAND_MAX+.5)); nBits = (8*sizeof(bitmask_t) - 1) / n; ndx = randX * (double)((bitmask_t)1 << (nBits*n)); /* get coordinate on Hilbert curve */ @@ -459,7 +459,7 @@ SDmultiSamp(double t[], int n, double randX) /* convert back to [0,1) range */ scale = 1. / (double)((bitmask_t)1 << nBits); while (n--) - t[n] = scale * ((double)coord[n] + rand()*(1./RAND_MAX)); + t[n] = scale * ((double)coord[n] + rand()*(1./(RAND_MAX+.5))); } #undef MS_MAXDIM