ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/raytrace.c
Revision: 2.31
Committed: Wed Jun 17 12:53:06 1998 UTC (25 years, 10 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 2.30: +11 -3 lines
Log Message:
improved the way ray weights are computed for participating media

File Contents

# User Rev Content
1 gwlarson 2.31 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2 greg 1.1
3     #ifndef lint
4 gwlarson 2.31 static char SCCSid[] = "$SunId$ SGI";
5 greg 1.1 #endif
6    
7     /*
8     * raytrace.c - routines for tracing and shading rays.
9     *
10     * 8/7/85
11     */
12    
13     #include "ray.h"
14    
15     #include "octree.h"
16    
17     #include "otypes.h"
18    
19 greg 1.15 #include "otspecial.h"
20    
21 greg 2.3 #define MAXCSET ((MAXSET+1)*2-1) /* maximum check set size */
22    
23 greg 1.1 extern CUBE thescene; /* our scene */
24     extern int maxdepth; /* maximum recursion depth */
25     extern double minweight; /* minimum ray weight */
26 greg 1.15 extern int do_irrad; /* compute irradiance? */
27 greg 2.23 extern COLOR ambval; /* ambient value */
28 greg 1.1
29 greg 2.23 extern COLOR cextinction; /* global extinction coefficient */
30 greg 2.26 extern COLOR salbedo; /* global scattering albedo */
31 greg 2.23 extern double seccg; /* global scattering eccentricity */
32     extern double ssampdist; /* scatter sampling distance */
33    
34 greg 2.6 unsigned long raynum = 0; /* next unique ray number */
35     unsigned long nrays = 0; /* number of calls to localhit */
36 greg 1.1
37 greg 1.23 static FLOAT Lambfa[5] = {PI, PI, PI, 0.0, 0.0};
38 greg 1.15 OBJREC Lamb = {
39     OVOID, MAT_PLASTIC, "Lambertian",
40 greg 2.2 {0, 5, NULL, Lambfa}, NULL,
41 greg 1.15 }; /* a Lambertian surface */
42    
43 greg 2.17 OBJREC Aftplane; /* aft clipping plane object */
44 greg 2.16
45 greg 2.5 static int raymove(), checkset(), checkhit();
46    
47 greg 1.6 #define MAXLOOP 128 /* modifier loop detection */
48 greg 1.1
49     #define RAYHIT (-1) /* return value for intercepted ray */
50    
51    
52     rayorigin(r, ro, rt, rw) /* start new ray from old one */
53     register RAY *r, *ro;
54     int rt;
55     double rw;
56     {
57 gwlarson 2.31 double re;
58    
59 greg 1.1 if ((r->parent = ro) == NULL) { /* primary ray */
60     r->rlvl = 0;
61     r->rweight = rw;
62     r->crtype = r->rtype = rt;
63     r->rsrc = -1;
64     r->clipset = NULL;
65 greg 1.21 r->revf = raytrace;
66 greg 2.23 copycolor(r->cext, cextinction);
67 greg 2.26 copycolor(r->albedo, salbedo);
68 greg 2.23 r->gecc = seccg;
69     r->slights = NULL;
70 greg 1.1 } else { /* spawned ray */
71     r->rlvl = ro->rlvl;
72     if (rt & RAYREFL) {
73     r->rlvl++;
74     r->rsrc = -1;
75     r->clipset = ro->clipset;
76 greg 2.22 r->rmax = 0.0;
77 greg 1.1 } else {
78     r->rsrc = ro->rsrc;
79     r->clipset = ro->newcset;
80 greg 2.22 r->rmax = ro->rmax <= FTINY ? 0.0 : ro->rmax - ro->rot;
81 greg 1.1 }
82 greg 1.21 r->revf = ro->revf;
83 greg 2.23 copycolor(r->cext, ro->cext);
84 greg 2.26 copycolor(r->albedo, ro->albedo);
85 greg 2.23 r->gecc = ro->gecc;
86     r->slights = ro->slights;
87 greg 1.1 r->crtype = ro->crtype | (r->rtype = rt);
88     VCOPY(r->rorg, ro->rop);
89 gwlarson 2.31 r->rweight = ro->rweight * rw;
90     /* estimate absorption */
91     re = colval(ro->cext,RED) < colval(ro->cext,GRN) ?
92     colval(ro->cext,RED) : colval(ro->cext,GRN);
93     if (colval(ro->cext,BLU) < re) re = colval(ro->cext,BLU);
94     if (re > 0.)
95     r->rweight *= exp(-re*ro->rot);
96 greg 1.1 }
97 greg 1.22 rayclear(r);
98     return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1);
99     }
100    
101    
102     rayclear(r) /* clear a ray for (re)evaluation */
103     register RAY *r;
104     {
105 greg 1.20 r->rno = raynum++;
106 greg 1.1 r->newcset = r->clipset;
107 greg 2.28 r->robj = OVOID;
108 greg 2.17 r->ro = NULL;
109 gregl 2.29 r->rt = r->rot = FHUGE;
110 greg 1.1 r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
111     setcolor(r->pcol, 1.0, 1.0, 1.0);
112     setcolor(r->rcol, 0.0, 0.0, 0.0);
113     }
114    
115    
116 greg 1.21 raytrace(r) /* trace a ray and compute its value */
117 greg 1.8 RAY *r;
118 greg 1.1 {
119     extern int (*trace)();
120    
121 greg 1.15 if (localhit(r, &thescene))
122 greg 2.24 raycont(r); /* hit local surface, evaluate */
123 greg 2.16 else if (r->ro == &Aftplane) {
124 greg 2.23 r->ro = NULL; /* hit aft clipping plane */
125 greg 2.16 r->rot = FHUGE;
126     } else if (sourcehit(r))
127 greg 2.24 rayshade(r, r->ro->omod); /* distant source */
128 greg 1.1
129 greg 2.23 rayparticipate(r); /* for participating medium */
130    
131 greg 1.1 if (trace != NULL)
132     (*trace)(r); /* trace execution */
133     }
134    
135    
136 greg 1.8 raycont(r) /* check for clipped object and continue */
137     register RAY *r;
138     {
139 greg 2.7 if ((r->clipset != NULL && inset(r->clipset, r->ro->omod)) ||
140 greg 2.24 !rayshade(r, r->ro->omod))
141 greg 1.8 raytrans(r);
142     }
143    
144    
145 greg 1.1 raytrans(r) /* transmit ray as is */
146 greg 1.8 register RAY *r;
147 greg 1.1 {
148     RAY tr;
149    
150     if (rayorigin(&tr, r, TRANS, 1.0) == 0) {
151     VCOPY(tr.rdir, r->rdir);
152     rayvalue(&tr);
153     copycolor(r->rcol, tr.rcol);
154 greg 1.10 r->rt = r->rot + tr.rt;
155 greg 1.1 }
156     }
157    
158    
159     rayshade(r, mod) /* shade ray r with material mod */
160     register RAY *r;
161     int mod;
162     {
163     static int depth = 0;
164 greg 2.9 int gotmat;
165 greg 1.1 register OBJREC *m;
166     /* check for infinite loop */
167     if (depth++ >= MAXLOOP)
168 greg 1.4 objerror(r->ro, USER, "possible modifier loop");
169 greg 1.19 r->rt = r->rot; /* set effective ray length */
170 greg 2.9 for (gotmat = 0; !gotmat && mod != OVOID; mod = m->omod) {
171 greg 1.1 m = objptr(mod);
172 greg 1.4 /****** unnecessary test since modifier() is always called
173 greg 1.1 if (!ismodifier(m->otype)) {
174     sprintf(errmsg, "illegal modifier \"%s\"", m->oname);
175     error(USER, errmsg);
176     }
177 greg 1.4 ******/
178 greg 1.16 /* hack for irradiance calculation */
179     if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS))) {
180     if (irr_ignore(m->otype)) {
181     depth--;
182     raytrans(r);
183 greg 2.15 return(1);
184 greg 1.16 }
185 greg 1.18 if (!islight(m->otype))
186 greg 1.16 m = &Lamb;
187     }
188 greg 2.9 /* materials call raytexture */
189     gotmat = (*ofun[m->otype].funp)(m, r);
190 greg 1.1 }
191 greg 2.9 depth--;
192     return(gotmat);
193 greg 2.23 }
194    
195    
196     rayparticipate(r) /* compute ray medium participation */
197     register RAY *r;
198     {
199     COLOR ce, ca;
200     double re, ge, be;
201    
202     if (intens(r->cext) <= 1./FHUGE)
203     return; /* no medium */
204 greg 2.27 re = r->rot*colval(r->cext,RED);
205     ge = r->rot*colval(r->cext,GRN);
206     be = r->rot*colval(r->cext,BLU);
207 greg 2.26 if (r->crtype & SHADOW) { /* no scattering for sources */
208     re *= 1. - colval(r->albedo,RED);
209     ge *= 1. - colval(r->albedo,GRN);
210     be *= 1. - colval(r->albedo,BLU);
211     }
212     setcolor(ce, re<=0. ? 1. : re>92. ? 0. : exp(-re),
213     ge<=0. ? 1. : ge>92. ? 0. : exp(-ge),
214     be<=0. ? 1. : be>92. ? 0. : exp(-be));
215 greg 2.23 multcolor(r->rcol, ce); /* path absorption */
216 greg 2.26 if (r->crtype & SHADOW || intens(r->albedo) <= FTINY)
217 greg 2.23 return; /* no scattering */
218 greg 2.26 setcolor(ca,
219     colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)),
220     colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)),
221     colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU)));
222 greg 2.23 addcolor(r->rcol, ca); /* ambient in scattering */
223     srcscatter(r); /* source in scattering */
224 greg 1.1 }
225    
226    
227     raytexture(r, mod) /* get material modifiers */
228     RAY *r;
229     int mod;
230     {
231     static int depth = 0;
232     register OBJREC *m;
233     /* check for infinite loop */
234     if (depth++ >= MAXLOOP)
235     objerror(r->ro, USER, "modifier loop");
236     /* execute textures and patterns */
237     for ( ; mod != OVOID; mod = m->omod) {
238     m = objptr(mod);
239 greg 2.9 /****** unnecessary test since modifier() is always called
240     if (!ismodifier(m->otype)) {
241 greg 1.1 sprintf(errmsg, "illegal modifier \"%s\"", m->oname);
242     error(USER, errmsg);
243     }
244 greg 2.9 ******/
245 greg 2.20 if ((*ofun[m->otype].funp)(m, r)) {
246     sprintf(errmsg, "conflicting material \"%s\"",
247     m->oname);
248     objerror(r->ro, USER, errmsg);
249     }
250 greg 1.1 }
251     depth--; /* end here */
252     }
253    
254    
255     raymixture(r, fore, back, coef) /* mix modifiers */
256     register RAY *r;
257     OBJECT fore, back;
258     double coef;
259     {
260 greg 2.9 RAY fr, br;
261     int foremat, backmat;
262 greg 1.1 register int i;
263 greg 2.24 /* bound coefficient */
264 greg 1.1 if (coef > 1.0)
265     coef = 1.0;
266     else if (coef < 0.0)
267     coef = 0.0;
268 greg 2.13 /* compute foreground and background */
269 greg 2.24 foremat = backmat = 0;
270 greg 2.9 /* foreground */
271     copystruct(&fr, r);
272 greg 2.24 if (coef > FTINY)
273 greg 2.9 foremat = rayshade(&fr, fore);
274     /* background */
275     copystruct(&br, r);
276 greg 2.24 if (coef < 1.0-FTINY)
277 greg 2.9 backmat = rayshade(&br, back);
278 greg 2.24 /* check for transparency */
279     if (backmat ^ foremat)
280 gwlarson 2.30 if (backmat && coef > FTINY)
281 greg 2.24 raytrans(&fr);
282 gwlarson 2.30 else if (foremat && coef < 1.0-FTINY)
283 greg 2.24 raytrans(&br);
284 greg 2.12 /* mix perturbations */
285 greg 1.1 for (i = 0; i < 3; i++)
286 greg 2.12 r->pert[i] = coef*fr.pert[i] + (1.0-coef)*br.pert[i];
287     /* mix pattern colors */
288 greg 2.9 scalecolor(fr.pcol, coef);
289     scalecolor(br.pcol, 1.0-coef);
290 greg 2.12 copycolor(r->pcol, fr.pcol);
291     addcolor(r->pcol, br.pcol);
292 greg 2.24 /* return value tells if material */
293     if (!foremat & !backmat)
294     return(0);
295 greg 2.12 /* mix returned ray values */
296 greg 2.24 scalecolor(fr.rcol, coef);
297     scalecolor(br.rcol, 1.0-coef);
298     copycolor(r->rcol, fr.rcol);
299     addcolor(r->rcol, br.rcol);
300     r->rt = bright(fr.rcol) > bright(br.rcol) ? fr.rt : br.rt;
301     return(1);
302 greg 1.1 }
303    
304    
305     double
306 greg 2.21 raydist(r, flags) /* compute (cumulative) ray distance */
307     register RAY *r;
308     register int flags;
309     {
310     double sum = 0.0;
311    
312     while (r != NULL && r->crtype&flags) {
313     sum += r->rot;
314     r = r->parent;
315     }
316     return(sum);
317     }
318    
319    
320     double
321 greg 1.1 raynormal(norm, r) /* compute perturbed normal for ray */
322     FVECT norm;
323     register RAY *r;
324     {
325     double newdot;
326     register int i;
327    
328     /* The perturbation is added to the surface normal to obtain
329     * the new normal. If the new normal would affect the surface
330     * orientation wrt. the ray, a correction is made. The method is
331     * still fraught with problems since reflected rays and similar
332     * directions calculated from the surface normal may spawn rays behind
333     * the surface. The only solution is to curb textures at high
334 greg 1.9 * incidence (namely, keep DOT(rdir,pert) < Rdot).
335 greg 1.1 */
336    
337     for (i = 0; i < 3; i++)
338     norm[i] = r->ron[i] + r->pert[i];
339    
340     if (normalize(norm) == 0.0) {
341     objerror(r->ro, WARNING, "illegal normal perturbation");
342     VCOPY(norm, r->ron);
343     return(r->rod);
344     }
345     newdot = -DOT(norm, r->rdir);
346     if ((newdot > 0.0) != (r->rod > 0.0)) { /* fix orientation */
347     for (i = 0; i < 3; i++)
348     norm[i] += 2.0*newdot*r->rdir[i];
349     newdot = -newdot;
350     }
351     return(newdot);
352 greg 1.12 }
353    
354    
355     newrayxf(r) /* get new tranformation matrix for ray */
356     RAY *r;
357     {
358     static struct xfn {
359     struct xfn *next;
360     FULLXF xf;
361     } xfseed = { &xfseed }, *xflast = &xfseed;
362     register struct xfn *xp;
363     register RAY *rp;
364    
365     /*
366     * Search for transform in circular list that
367     * has no associated ray in the tree.
368     */
369     xp = xflast;
370     for (rp = r->parent; rp != NULL; rp = rp->parent)
371     if (rp->rox == &xp->xf) { /* xp in use */
372     xp = xp->next; /* move to next */
373     if (xp == xflast) { /* need new one */
374 greg 1.14 xp = (struct xfn *)bmalloc(sizeof(struct xfn));
375 greg 1.12 if (xp == NULL)
376     error(SYSTEM,
377     "out of memory in newrayxf");
378     /* insert in list */
379     xp->next = xflast->next;
380     xflast->next = xp;
381     break; /* we're done */
382     }
383     rp = r; /* start check over */
384     }
385     /* got it */
386     r->rox = &xp->xf;
387     xflast = xp;
388 greg 1.1 }
389    
390    
391     flipsurface(r) /* reverse surface orientation */
392     register RAY *r;
393     {
394     r->rod = -r->rod;
395     r->ron[0] = -r->ron[0];
396     r->ron[1] = -r->ron[1];
397     r->ron[2] = -r->ron[2];
398     r->pert[0] = -r->pert[0];
399     r->pert[1] = -r->pert[1];
400     r->pert[2] = -r->pert[2];
401     }
402    
403    
404     localhit(r, scene) /* check for hit in the octree */
405     register RAY *r;
406     register CUBE *scene;
407     {
408 greg 2.3 OBJECT cxset[MAXCSET+1]; /* set of checked objects */
409 greg 1.1 FVECT curpos; /* current cube position */
410 greg 1.11 int sflags; /* sign flags */
411 greg 1.1 double t, dt;
412     register int i;
413    
414 greg 1.21 nrays++; /* increment trace counter */
415 greg 1.11 sflags = 0;
416 greg 1.1 for (i = 0; i < 3; i++) {
417     curpos[i] = r->rorg[i];
418 greg 2.8 if (r->rdir[i] > 1e-7)
419 greg 1.11 sflags |= 1 << i;
420 greg 2.8 else if (r->rdir[i] < -1e-7)
421 greg 1.11 sflags |= 0x10 << i;
422 greg 1.1 }
423 greg 1.17 if (sflags == 0)
424     error(CONSISTENCY, "zero ray direction in localhit");
425 greg 2.17 /* start off assuming nothing hit */
426     if (r->rmax > FTINY) { /* except aft plane if one */
427     r->ro = &Aftplane;
428     r->rot = r->rmax;
429     for (i = 0; i < 3; i++)
430     r->rop[i] = r->rorg[i] + r->rot*r->rdir[i];
431     }
432     /* find global cube entrance point */
433 greg 1.1 t = 0.0;
434     if (!incube(scene, curpos)) {
435     /* find distance to entry */
436     for (i = 0; i < 3; i++) {
437     /* plane in our direction */
438 greg 1.11 if (sflags & 1<<i)
439 greg 1.1 dt = scene->cuorg[i];
440 greg 1.11 else if (sflags & 0x10<<i)
441 greg 1.1 dt = scene->cuorg[i] + scene->cusize;
442     else
443     continue;
444     /* distance to the plane */
445     dt = (dt - r->rorg[i])/r->rdir[i];
446     if (dt > t)
447     t = dt; /* farthest face is the one */
448     }
449     t += FTINY; /* fudge to get inside cube */
450 greg 2.17 if (t >= r->rot) /* clipped already */
451     return(0);
452 greg 1.1 /* advance position */
453     for (i = 0; i < 3; i++)
454     curpos[i] += r->rdir[i]*t;
455    
456     if (!incube(scene, curpos)) /* non-intersecting ray */
457     return(0);
458     }
459 greg 2.3 cxset[0] = 0;
460 greg 2.19 raymove(curpos, cxset, sflags, r, scene);
461     return(r->ro != NULL & r->ro != &Aftplane);
462 greg 1.1 }
463    
464    
465     static int
466 greg 2.3 raymove(pos, cxs, dirf, r, cu) /* check for hit as we move */
467     FVECT pos; /* current position, modified herein */
468     OBJECT *cxs; /* checked objects, modified by checkhit */
469 greg 1.11 int dirf; /* direction indicators to speed tests */
470 greg 1.1 register RAY *r;
471     register CUBE *cu;
472     {
473     int ax;
474     double dt, t;
475    
476     if (istree(cu->cutree)) { /* recurse on subcubes */
477     CUBE cukid;
478 greg 1.11 register int br, sgn;
479 greg 1.1
480     cukid.cusize = cu->cusize * 0.5; /* find subcube */
481     VCOPY(cukid.cuorg, cu->cuorg);
482     br = 0;
483     if (pos[0] >= cukid.cuorg[0]+cukid.cusize) {
484     cukid.cuorg[0] += cukid.cusize;
485     br |= 1;
486     }
487     if (pos[1] >= cukid.cuorg[1]+cukid.cusize) {
488     cukid.cuorg[1] += cukid.cusize;
489     br |= 2;
490     }
491     if (pos[2] >= cukid.cuorg[2]+cukid.cusize) {
492     cukid.cuorg[2] += cukid.cusize;
493     br |= 4;
494     }
495     for ( ; ; ) {
496     cukid.cutree = octkid(cu->cutree, br);
497 greg 2.3 if ((ax = raymove(pos,cxs,dirf,r,&cukid)) == RAYHIT)
498 greg 1.1 return(RAYHIT);
499     sgn = 1 << ax;
500 greg 1.11 if (sgn & dirf) /* positive axis? */
501 greg 1.1 if (sgn & br)
502     return(ax); /* overflow */
503     else {
504     cukid.cuorg[ax] += cukid.cusize;
505     br |= sgn;
506     }
507 greg 1.11 else
508     if (sgn & br) {
509     cukid.cuorg[ax] -= cukid.cusize;
510     br &= ~sgn;
511     } else
512     return(ax); /* underflow */
513 greg 1.1 }
514     /*NOTREACHED*/
515     }
516 greg 2.18 if (isfull(cu->cutree)) {
517     if (checkhit(r, cu, cxs))
518     return(RAYHIT);
519     } else if (r->ro == &Aftplane && incube(cu, r->rop))
520 greg 1.1 return(RAYHIT);
521     /* advance to next cube */
522 greg 1.11 if (dirf&0x11) {
523     dt = dirf&1 ? cu->cuorg[0] + cu->cusize : cu->cuorg[0];
524 greg 1.1 t = (dt - pos[0])/r->rdir[0];
525     ax = 0;
526     } else
527     t = FHUGE;
528 greg 1.11 if (dirf&0x22) {
529     dt = dirf&2 ? cu->cuorg[1] + cu->cusize : cu->cuorg[1];
530 greg 1.1 dt = (dt - pos[1])/r->rdir[1];
531     if (dt < t) {
532     t = dt;
533     ax = 1;
534     }
535     }
536 greg 1.11 if (dirf&0x44) {
537     dt = dirf&4 ? cu->cuorg[2] + cu->cusize : cu->cuorg[2];
538 greg 1.1 dt = (dt - pos[2])/r->rdir[2];
539     if (dt < t) {
540     t = dt;
541     ax = 2;
542     }
543     }
544     pos[0] += r->rdir[0]*t;
545     pos[1] += r->rdir[1]*t;
546     pos[2] += r->rdir[2]*t;
547     return(ax);
548     }
549    
550    
551     static
552 greg 2.3 checkhit(r, cu, cxs) /* check for hit in full cube */
553 greg 1.1 register RAY *r;
554     CUBE *cu;
555 greg 2.3 OBJECT *cxs;
556 greg 1.1 {
557     OBJECT oset[MAXSET+1];
558     register OBJREC *o;
559     register int i;
560    
561     objset(oset, cu->cutree);
562 greg 2.3 checkset(oset, cxs); /* eliminate double-checking */
563 greg 1.1 for (i = oset[0]; i > 0; i--) {
564     o = objptr(oset[i]);
565 greg 2.28 if ((*ofun[o->otype].funp)(o, r))
566     r->robj = oset[i];
567 greg 1.1 }
568     if (r->ro == NULL)
569     return(0); /* no scores yet */
570    
571     return(incube(cu, r->rop)); /* hit OK if in current cube */
572 greg 2.2 }
573    
574    
575     static
576     checkset(os, cs) /* modify checked set and set to check */
577 greg 2.3 register OBJECT *os; /* os' = os - cs */
578     register OBJECT *cs; /* cs' = cs + os */
579 greg 2.2 {
580     OBJECT cset[MAXCSET+MAXSET+1];
581 greg 2.3 register int i, j;
582     int k;
583 greg 2.2 /* copy os in place, cset <- cs */
584     cset[0] = 0;
585     k = 0;
586     for (i = j = 1; i <= os[0]; i++) {
587     while (j <= cs[0] && cs[j] < os[i])
588     cset[++cset[0]] = cs[j++];
589     if (j > cs[0] || os[i] != cs[j]) { /* object to check */
590     os[++k] = os[i];
591     cset[++cset[0]] = os[i];
592     }
593     }
594 greg 2.3 if (!(os[0] = k)) /* new "to check" set size */
595     return; /* special case */
596 greg 2.2 while (j <= cs[0]) /* get the rest of cs */
597     cset[++cset[0]] = cs[j++];
598 greg 2.3 if (cset[0] > MAXCSET) /* truncate "checked" set if nec. */
599 greg 2.2 cset[0] = MAXCSET;
600 greg 2.3 /* setcopy(cs, cset); */ /* copy cset back to cs */
601     os = cset;
602     for (i = os[0]; i-- >= 0; )
603     *cs++ = *os++;
604 greg 1.1 }