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.6 by greg, Thu Jul 25 12:52:18 1991 UTC vs.
Revision 1.10 by greg, Tue Aug 13 13:45:18 1991 UTC

# Line 38 | Line 38 | struct rtproc  *rt;
38   char  *nm;
39   {
40   #define MAXMISS         (5*n*il->nsamps)
41 <        int  dim[4];
42 <        int  n, nalt, nazi;
41 >        int  dim[3];
42 >        int  n, nalt, nazi, h;
43          float  *distarr;
44 <        double  r1, r2;
44 >        double  sp[2], r1, r2;
45          FVECT  dn, org, dir;
46          FVECT  u, v;
47          double  ur[2], vr[2];
# Line 81 | Line 81 | char  *nm;
81              for (dim[2] = 0; dim[2] < nazi; dim[2]++)
82                  for (i = 0; i < il->nsamps; i++) {
83                                          /* random direction */
84 <                    dim[3] = 1;
85 <                    r1 = (dim[1]+urand(urind(ilhash(dim,4),i)))/nalt;
86 <                    dim[3] = 2;
87 <                    r2 = (dim[2]+urand(urind(ilhash(dim,4),i)))/nazi;
84 >                    h = ilhash(dim, 3) + i;
85 >                    peano(sp, 2, urand(h), .02);
86 >                    r1 = (dim[1] + sp[0])/nalt;
87 >                    r2 = (dim[2] + sp[1])/nazi;
88                      flatdir(dn, r1, r2);
89                      for (j = 0; j < 3; j++)
90                          dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*fa->norm[j];
91                                          /* random location */
92                      do {
93 <                        dim[3] = 3;
94 <                        r1 = ur[0] + (ur[1]-ur[0]) *
95 <                                        urand(urind(ilhash(dim,4),i+nmisses));
96 <                        dim[3] = 4;
97 <                        r2 = vr[0] + (vr[1]-vr[0]) *
98 <                                        urand(urind(ilhash(dim,4),i+nmisses));
93 >                        peano(sp, 2, urand(h+nmisses), .01);
94 >                        r1 = ur[0] + (ur[1]-ur[0]) * sp[0];
95 >                        r2 = vr[0] + (vr[1]-vr[0]) * sp[1];
96                          for (j = 0; j < 3; j++)
97                              org[j] = r1*u[j] + r2*v[j]
98                                          + fa->offset*fa->norm[j];
# Line 111 | Line 108 | char  *nm;
108                      for (j = 0; j < 3; j++)
109                          org[j] += .001*fa->norm[j];
110                                          /* send sample */
111 <                    raysamp(distarr+dim[1]*nazi+dim[2], org, dir, rt);
111 >                    raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt);
112                  }
113          rayflush(rt);
114                                  /* write out the face w/ distribution */
# Line 130 | Line 127 | struct illum_args  *il;
127   struct rtproc  *rt;
128   char  *nm;
129   {
130 <        int  dim[4];
130 >        int  dim[3];
131          int  n, nalt, nazi;
132          float  *distarr;
133 <        double  r1, r2, r3;
133 >        double  sp[4], r1, r2, r3;
134          FVECT  org, dir;
135          FVECT  u, v;
136          register int  i, j;
# Line 151 | Line 148 | char  *nm;
148          dim[0] = random();
149                                  /* sample sphere */
150          for (dim[1] = 0; dim[1] < nalt; dim[1]++)
151 <            for (dim[2] = 0; dim[2] < nazi; dim[2]++) {
155 <                if (il->nsamps > 2 && nazi > 20) {
156 <                    rounddir(dir, (dim[1]+.5)/nalt, (dim[2]+.5)/nazi);
157 <                    mkaxes(u, v, dir);
158 <                }
151 >            for (dim[2] = 0; dim[2] < nazi; dim[2]++)
152                  for (i = 0; i < il->nsamps; i++) {
153 +                                        /* next sample point */
154 +                    peano(sp, 4, urand(ilhash(dim,3)+i), .02);
155                                          /* random direction */
156 <                    dim[3] = 1;
157 <                    r1 = (dim[1]+urand(urind(ilhash(dim,4),i)))/nalt;
163 <                    dim[3] = 2;
164 <                    r2 = (dim[2]+urand(urind(ilhash(dim,4),i)))/nazi;
156 >                    r1 = (dim[1] + sp[0])/nalt;
157 >                    r2 = (dim[2] + sp[1])/nazi;
158                      rounddir(dir, r1, r2);
159                                          /* random location */
160 <                    if (il->nsamps <= 2 || nazi <= 20)
161 <                        mkaxes(u, v, dir);              /* yuck! */
162 <                    dim[3] = 3;
170 <                    r3 = sqrt(urand(urind(ilhash(dim,4),i)));
171 <                    dim[3] = 4;
172 <                    r2 = 2.*PI*urand(urind(ilhash(dim,4),i));
160 >                    mkaxes(u, v, dir);          /* yuck! */
161 >                    r3 = sqrt(sp[2]);
162 >                    r2 = 2.*PI*sp[3];
163                      r1 = r3*ob->oargs.farg[3]*cos(r2);
164                      r2 = r3*ob->oargs.farg[3]*sin(r2);
165                      r3 = ob->oargs.farg[3]*sqrt(1.01-r3*r3);
# Line 179 | Line 169 | char  *nm;
169                          dir[j] = -dir[j];
170                      }
171                                          /* send sample */
172 <                    raysamp(distarr+dim[1]*nazi+dim[2], org, dir, rt);
172 >                    raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt);
173                  }
184            }
174          rayflush(rt);
175                                  /* write out the sphere w/ distribution */
176          roundout(il, distarr, nalt, nazi);
# Line 197 | Line 186 | struct illum_args  *il;
186   struct rtproc  *rt;
187   char  *nm;
188   {
189 <        int  dim[4];
189 >        int  dim[3];
190          int  n, nalt, nazi;
191          float  *distarr;
192 <        double  r1, r2, r3;
192 >        double  sp[4], r1, r2, r3;
193          FVECT  dn, org, dir;
194          FVECT  u, v;
195          register CONE  *co;
# Line 221 | Line 210 | char  *nm;
210          for (dim[1] = 0; dim[1] < nalt; dim[1]++)
211              for (dim[2] = 0; dim[2] < nazi; dim[2]++)
212                  for (i = 0; i < il->nsamps; i++) {
213 +                                        /* next sample point */
214 +                    peano(sp, 4, urand(ilhash(dim,3)+i), .02);
215                                          /* random direction */
216 <                    dim[3] = 1;
217 <                    r1 = (dim[1]+urand(urind(ilhash(dim,4),i)))/nalt;
227 <                    dim[3] = 2;
228 <                    r2 = (dim[2]+urand(urind(ilhash(dim,4),i)))/nalt;
216 >                    r1 = (dim[1] + sp[0])/nalt;
217 >                    r2 = (dim[2] + sp[1])/nalt;
218                      flatdir(dn, r1, r2);
219                      for (j = 0; j < 3; j++)
220                          dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*co->ad[j];
221                                          /* random location */
233                    dim[3] = 3;
222                      r3 = sqrt(CO_R0(co)*CO_R0(co) +
223 <                                urand(urind(ilhash(dim,4),i))*
224 <                                (CO_R1(co)*CO_R1(co) - CO_R0(co)*CO_R0(co)));
237 <                    dim[3] = 4;
238 <                    r2 = 2.*PI*urand(urind(ilhash(dim,4),i));
223 >                            sp[2]*(CO_R1(co)*CO_R1(co) - CO_R0(co)*CO_R0(co)));
224 >                    r2 = 2.*PI*sp[3];
225                      r1 = r3*cos(r2);
226                      r2 = r3*sin(r2);
227                      for (j = 0; j < 3; j++)
# Line 243 | Line 229 | char  *nm;
229                                          .001*co->ad[j];
230  
231                                          /* send sample */
232 <                    raysamp(distarr+dim[1]*nazi+dim[2], org, dir, rt);
232 >                    raysamp(distarr+3*(dim[1]*nazi+dim[2]), org, dir, rt);
233                  }
234          rayflush(rt);
235                                  /* write out the ring w/ distribution */
# Line 278 | Line 264 | register struct rtproc  *rt;
264  
265          if (rt->nrays <= 0)
266                  return;
267 <        i = 6*rt->nrays + 3;
282 <        rt->buf[i++] = 0.; rt->buf[i++] = 0.; rt->buf[i] = 0.;
267 >        bzero(rt->buf+6*rt->nrays, 6*sizeof(float));
268          if ( process(rt->pd, (char *)rt->buf, (char *)rt->buf,
269                          3*sizeof(float)*rt->nrays,
270                          6*sizeof(float)*(rt->nrays+1)) <

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines