--- ray/src/gen/mkillum2.c 1991/08/13 13:45:18 1.10 +++ ray/src/gen/mkillum2.c 1991/08/26 10:16:56 1.13 @@ -56,9 +56,13 @@ char *nm; return; } /* set up sampling */ - n = PI * il->sampdens; - nalt = sqrt(n/PI) + .5; - nazi = PI*nalt + .5; + if (il->sampdens <= 0) + nalt = nazi = 1; + else { + n = PI * il->sampdens; + nalt = sqrt(n/PI) + .5; + nazi = PI*nalt + .5; + } n = nalt*nazi; distarr = (float *)calloc(n, 3*sizeof(float)); if (distarr == NULL) @@ -82,15 +86,15 @@ char *nm; for (i = 0; i < il->nsamps; i++) { /* random direction */ h = ilhash(dim, 3) + i; - peano(sp, 2, urand(h), .02); + multisamp(sp, 2, urand(h)); r1 = (dim[1] + sp[0])/nalt; - r2 = (dim[2] + sp[1])/nazi; + r2 = (dim[2] + sp[1] - .5)/nazi; flatdir(dn, r1, r2); for (j = 0; j < 3; j++) dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*fa->norm[j]; /* random location */ do { - peano(sp, 2, urand(h+nmisses), .01); + multisamp(sp, 2, urand(h+4862+nmisses)); r1 = ur[0] + (ur[1]-ur[0]) * sp[0]; r2 = vr[0] + (vr[1]-vr[0]) * sp[1]; for (j = 0; j < 3; j++) @@ -111,9 +115,13 @@ char *nm; raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt); } rayflush(rt); - /* write out the face w/ distribution */ - flatout(il, distarr, nalt, nazi, u, v, fa->norm); - illumout(il, ob); + /* write out the face and its distribution */ + if (average(il, distarr, nalt*nazi)) { + if (il->sampdens > 0) + flatout(il, distarr, nalt, nazi, u, v, fa->norm); + illumout(il, ob); + } else if (!(il->flags & IL_LIGHT)) + printobj(il->altmat, ob); /* clean up */ freeface(ob); free((char *)distarr); @@ -138,9 +146,13 @@ char *nm; if (ob->oargs.nfargs != 4) objerror(ob, USER, "bad # of arguments"); /* set up sampling */ - n = 4.*PI * il->sampdens; - nalt = sqrt(n/PI) + .5; - nazi = PI*nalt + .5; + if (il->sampdens <= 0) + nalt = nazi = 1; + else { + n = 4.*PI * il->sampdens; + nalt = sqrt(n/PI) + .5; + nazi = PI*nalt + .5; + } n = nalt*nazi; distarr = (float *)calloc(n, 3*sizeof(float)); if (distarr == NULL) @@ -151,10 +163,10 @@ char *nm; for (dim[2] = 0; dim[2] < nazi; dim[2]++) for (i = 0; i < il->nsamps; i++) { /* next sample point */ - peano(sp, 4, urand(ilhash(dim,3)+i), .02); + multisamp(sp, 4, urand(ilhash(dim,3)+i)); /* random direction */ r1 = (dim[1] + sp[0])/nalt; - r2 = (dim[2] + sp[1])/nazi; + r2 = (dim[2] + sp[1] - .5)/nazi; rounddir(dir, r1, r2); /* random location */ mkaxes(u, v, dir); /* yuck! */ @@ -172,9 +184,15 @@ char *nm; raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt); } rayflush(rt); - /* write out the sphere w/ distribution */ - roundout(il, distarr, nalt, nazi); - illumout(il, ob); + /* write out the sphere and its distribution */ + if (average(il, distarr, nalt*nazi)) { + if (il->sampdens > 0) + roundout(il, distarr, nalt, nazi); + else + objerror(ob, WARNING, "diffuse distribution"); + illumout(il, ob); + } else if (!(il->flags & IL_LIGHT)) + printobj(il->altmat, ob); /* clean up */ free((char *)distarr); } @@ -197,9 +215,13 @@ char *nm; /* get/check arguments */ co = getcone(ob, 0); /* set up sampling */ - n = PI * il->sampdens; - nalt = sqrt(n/PI) + .5; - nazi = PI*nalt + .5; + if (il->sampdens <= 0) + nalt = nazi = 1; + else { + n = PI * il->sampdens; + nalt = sqrt(n/PI) + .5; + nazi = PI*nalt + .5; + } n = nalt*nazi; distarr = (float *)calloc(n, 3*sizeof(float)); if (distarr == NULL) @@ -211,10 +233,10 @@ char *nm; for (dim[2] = 0; dim[2] < nazi; dim[2]++) for (i = 0; i < il->nsamps; i++) { /* next sample point */ - peano(sp, 4, urand(ilhash(dim,3)+i), .02); + multisamp(sp, 4, urand(ilhash(dim,3)+i)); /* random direction */ r1 = (dim[1] + sp[0])/nalt; - r2 = (dim[2] + sp[1])/nalt; + r2 = (dim[2] + sp[1] - .5)/nazi; flatdir(dn, r1, r2); for (j = 0; j < 3; j++) dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*co->ad[j]; @@ -232,9 +254,13 @@ char *nm; raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt); } rayflush(rt); - /* write out the ring w/ distribution */ - flatout(il, distarr, nalt, nazi, u, v, co->ad); - illumout(il, ob); + /* write out the ring and its distribution */ + if (average(il, distarr, nalt*nazi)) { + if (il->sampdens > 0) + flatout(il, distarr, nalt, nazi, u, v, co->ad); + illumout(il, ob); + } else if (!(il->flags & IL_LIGHT)) + printobj(il->altmat, ob); /* clean up */ freecone(ob); free((char *)distarr);