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

Comparing ray/src/gen/mkillum2.c (file contents):
Revision 1.10 by greg, Tue Aug 13 13:45:18 1991 UTC vs.
Revision 1.11 by greg, Thu Aug 22 12:12:23 1991 UTC

# Line 56 | Line 56 | char  *nm;
56                  return;
57          }
58                                  /* set up sampling */
59 <        n = PI * il->sampdens;
60 <        nalt = sqrt(n/PI) + .5;
61 <        nazi = PI*nalt + .5;
59 >        if (il->sampdens <= 0)
60 >                nalt = nazi = 1;
61 >        else {
62 >                n = PI * il->sampdens;
63 >                nalt = sqrt(n/PI) + .5;
64 >                nazi = PI*nalt + .5;
65 >        }
66          n = nalt*nazi;
67          distarr = (float *)calloc(n, 3*sizeof(float));
68          if (distarr == NULL)
# Line 82 | Line 86 | char  *nm;
86                  for (i = 0; i < il->nsamps; i++) {
87                                          /* random direction */
88                      h = ilhash(dim, 3) + i;
89 <                    peano(sp, 2, urand(h), .02);
89 >                    multisamp(sp, 2, urand(h));
90                      r1 = (dim[1] + sp[0])/nalt;
91                      r2 = (dim[2] + sp[1])/nazi;
92                      flatdir(dn, r1, r2);
# Line 90 | Line 94 | char  *nm;
94                          dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*fa->norm[j];
95                                          /* random location */
96                      do {
97 <                        peano(sp, 2, urand(h+nmisses), .01);
97 >                        multisamp(sp, 2, urand(h+4862+nmisses));
98                          r1 = ur[0] + (ur[1]-ur[0]) * sp[0];
99                          r2 = vr[0] + (vr[1]-vr[0]) * sp[1];
100                          for (j = 0; j < 3; j++)
# Line 111 | Line 115 | char  *nm;
115                      raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt);
116                  }
117          rayflush(rt);
118 <                                /* write out the face w/ distribution */
119 <        flatout(il, distarr, nalt, nazi, u, v, fa->norm);
118 >                                /* write out the face and its distribution */
119 >        average(il, distarr, nalt*nazi);
120 >        if (il->sampdens > 0)
121 >                flatout(il, distarr, nalt, nazi, u, v, fa->norm);
122          illumout(il, ob);
123                                  /* clean up */
124          freeface(ob);
# Line 138 | Line 144 | char  *nm;
144          if (ob->oargs.nfargs != 4)
145                  objerror(ob, USER, "bad # of arguments");
146                                  /* set up sampling */
147 <        n = 4.*PI * il->sampdens;
148 <        nalt = sqrt(n/PI) + .5;
149 <        nazi = PI*nalt + .5;
147 >        if (il->sampdens <= 0)
148 >                nalt = nazi = 1;
149 >        else {
150 >                n = 4.*PI * il->sampdens;
151 >                nalt = sqrt(n/PI) + .5;
152 >                nazi = PI*nalt + .5;
153 >        }
154          n = nalt*nazi;
155          distarr = (float *)calloc(n, 3*sizeof(float));
156          if (distarr == NULL)
# Line 151 | Line 161 | char  *nm;
161              for (dim[2] = 0; dim[2] < nazi; dim[2]++)
162                  for (i = 0; i < il->nsamps; i++) {
163                                          /* next sample point */
164 <                    peano(sp, 4, urand(ilhash(dim,3)+i), .02);
164 >                    multisamp(sp, 4, urand(ilhash(dim,3)+i));
165                                          /* random direction */
166                      r1 = (dim[1] + sp[0])/nalt;
167                      r2 = (dim[2] + sp[1])/nazi;
# Line 172 | Line 182 | char  *nm;
182                      raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt);
183                  }
184          rayflush(rt);
185 <                                /* write out the sphere w/ distribution */
186 <        roundout(il, distarr, nalt, nazi);
185 >                                /* write out the sphere and its distribution */
186 >        average(il, distarr, nalt*nazi);
187 >        if (il->sampdens > 0)
188 >                roundout(il, distarr, nalt, nazi);
189 >        else
190 >                objerror(ob, WARNING, "diffuse distribution");
191          illumout(il, ob);
192                                  /* clean up */
193          free((char *)distarr);
# Line 197 | Line 211 | char  *nm;
211                                  /* get/check arguments */
212          co = getcone(ob, 0);
213                                  /* set up sampling */
214 <        n = PI * il->sampdens;
215 <        nalt = sqrt(n/PI) + .5;
216 <        nazi = PI*nalt + .5;
214 >        if (il->sampdens <= 0)
215 >                nalt = nazi = 1;
216 >        else {
217 >                n = PI * il->sampdens;
218 >                nalt = sqrt(n/PI) + .5;
219 >                nazi = PI*nalt + .5;
220 >        }
221          n = nalt*nazi;
222          distarr = (float *)calloc(n, 3*sizeof(float));
223          if (distarr == NULL)
# Line 211 | Line 229 | char  *nm;
229              for (dim[2] = 0; dim[2] < nazi; dim[2]++)
230                  for (i = 0; i < il->nsamps; i++) {
231                                          /* next sample point */
232 <                    peano(sp, 4, urand(ilhash(dim,3)+i), .02);
232 >                    multisamp(sp, 4, urand(ilhash(dim,3)+i));
233                                          /* random direction */
234                      r1 = (dim[1] + sp[0])/nalt;
235                      r2 = (dim[2] + sp[1])/nalt;
# Line 232 | Line 250 | char  *nm;
250                      raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt);
251                  }
252          rayflush(rt);
253 <                                /* write out the ring w/ distribution */
254 <        flatout(il, distarr, nalt, nazi, u, v, co->ad);
253 >                                /* write out the ring and its distribution */
254 >        average(il, distarr, nalt*nazi);
255 >        if (il->sampdens > 0)
256 >                flatout(il, distarr, nalt, nazi, u, v, co->ad);
257          illumout(il, ob);
258                                  /* clean up */
259          freecone(ob);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines