ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/ray.h
Revision: 2.31
Committed: Sat Dec 12 05:20:10 2009 UTC (14 years, 4 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.30: +5 -1 lines
Log Message:
Created FIFO calls for ray multiprocessing

File Contents

# User Rev Content
1 greg 2.31 /* RCSid $Id: ray.h,v 2.30 2009/12/12 00:03:42 greg Exp $ */
2 greg 1.1 /*
3     * ray.h - header file for routines using rays.
4 greg 2.12 */
5 schorsch 2.17 #ifndef _RAD_RAY_H_
6     #define _RAD_RAY_H_
7 greg 1.1
8     #include "standard.h"
9 greg 2.12 #include "octree.h"
10 greg 1.1 #include "object.h"
11 schorsch 2.20 #include "color.h"
12 greg 1.1
13 schorsch 2.20 #ifdef __cplusplus
14     extern "C" {
15     #endif
16 greg 1.1
17 greg 2.30 #ifndef RNUMBER
18     #define RNUMBER unsigned long /* ray counter (>= sizeof pointer) */
19     #endif
20    
21 greg 2.6 #define MAXDIM 32 /* maximum number of dimensions */
22    
23 greg 1.1 /* ray type flags */
24     #define PRIMARY 01 /* original ray */
25     #define SHADOW 02 /* ray to light source */
26     #define REFLECTED 04 /* reflected ray */
27     #define REFRACTED 010 /* refracted (bent) ray */
28     #define TRANS 020 /* transmitted/transferred ray */
29     #define AMBIENT 040 /* ray scattered for interreflection */
30 greg 2.2 #define SPECULAR 0100 /* ray scattered for specular */
31 greg 1.1
32     /* reflected ray types */
33 greg 2.2 #define RAYREFL (SHADOW|REFLECTED|AMBIENT|SPECULAR)
34 greg 1.1
35 greg 2.29 /* Arrange so double's come first for optimal alignment */
36     /* Pointers and long's come second for 64-bit mode */
37     /* Int's next (unknown length), then floats, followed by short's & char's */
38 greg 1.1 typedef struct ray {
39 greg 2.12 FVECT rorg; /* origin of ray */
40     FVECT rdir; /* normalized direction of ray */
41 greg 2.29 RREAL rmax; /* maximum distance (aft clipping plane) */
42     RREAL rot; /* distance to object */
43     FVECT rop; /* intersection point */
44     FVECT ron; /* intersection surface normal */
45     RREAL rod; /* -DOT(rdir, ron) */
46     RREAL uv[2]; /* local coordinates */
47     FVECT pert; /* surface normal perturbation */
48     RREAL rt; /* returned effective ray length */
49     const struct ray *parent; /* ray this originated from */
50 greg 2.12 OBJECT *clipset; /* set of objects currently clipped */
51     OBJECT *newcset; /* next clipset, used for transmission */
52 greg 2.26 void (*revf)(struct ray *); /* ray evaluation function */
53 greg 2.21 void (*hitf)(OBJECT *, struct ray *); /* custom hit test */
54 greg 2.12 OBJREC *ro; /* intersected object (one with material) */
55     FULLXF *rox; /* object transformation */
56 greg 2.29 int *slights; /* list of lights to test for scattering */
57 greg 2.30 RNUMBER rno; /* unique ray number */
58 greg 2.29 int rlvl; /* number of reflections for this ray */
59     int rsrc; /* source we're aiming for */
60     float rweight; /* cumulative weight (for termination) */
61     COLOR rcoef; /* contribution coefficient w.r.t. parent */
62 greg 2.12 COLOR pcol; /* pattern color */
63 greg 2.24 COLOR rcol; /* returned radiance value */
64 greg 2.12 COLOR cext; /* medium extinction coefficient */
65     COLOR albedo; /* medium scattering albedo */
66     float gecc; /* scattering eccentricity coefficient */
67 greg 2.29 OBJECT robj; /* intersected object number */
68     short rtype; /* ray type */
69     short crtype; /* cumulative ray type */
70 greg 1.1 } RAY;
71    
72 greg 2.26 #define rayvalue(r) (*(r)->revf)(r)
73    
74 greg 2.12 extern char VersionID[]; /* Radiance version ID string */
75 greg 1.6
76 greg 2.12 extern CUBE thescene; /* our scene */
77     extern OBJECT nsceneobjs; /* number of objects in our scene */
78 greg 2.5
79 greg 2.12 extern unsigned long raynum; /* next ray ID */
80     extern unsigned long nrays; /* total rays traced so far */
81 greg 1.5
82 greg 2.12 extern OBJREC Lamb; /* a Lambertian surface */
83     extern OBJREC Aftplane; /* aft clipping object */
84    
85     extern void (*trace)(); /* global trace reporting callback */
86    
87     extern int dimlist[]; /* dimension list for distribution */
88     extern int ndims; /* number of dimensions so far */
89     extern int samplendx; /* index for this sample */
90    
91     extern int ray_savesiz; /* size of parameter save buffer */
92    
93     extern int do_irrad; /* compute irradiance? */
94    
95 greg 2.27 extern int rand_samp; /* pure Monte Carlo sampling? */
96    
97 greg 2.12 extern double dstrsrc; /* square source distribution */
98     extern double shadthresh; /* shadow threshold */
99     extern double shadcert; /* shadow testing certainty */
100     extern int directrelay; /* number of source relays */
101     extern int vspretest; /* virtual source pretest density */
102     extern int directvis; /* light sources visible to eye? */
103     extern double srcsizerat; /* maximum source size/dist. ratio */
104    
105     extern double specthresh; /* specular sampling threshold */
106     extern double specjitter; /* specular sampling jitter */
107    
108     extern COLOR cextinction; /* global extinction coefficient */
109     extern COLOR salbedo; /* global scattering albedo */
110     extern double seccg; /* global scattering eccentricity */
111     extern double ssampdist; /* scatter sampling distance */
112    
113     extern int backvis; /* back face visibility */
114    
115     extern int maxdepth; /* maximum recursion depth */
116     extern double minweight; /* minimum ray weight */
117    
118     extern char *ambfile; /* ambient file name */
119     extern COLOR ambval; /* ambient value */
120     extern int ambvwt; /* initial weight for ambient value */
121     extern double ambacc; /* ambient accuracy */
122     extern int ambres; /* ambient resolution */
123     extern int ambdiv; /* ambient divisions */
124     extern int ambssamp; /* ambient super-samples */
125     extern int ambounce; /* ambient bounces */
126     extern char *amblist[]; /* ambient include/exclude list */
127     extern int ambincl; /* include == 1, exclude == 0 */
128    
129     extern int ray_pnprocs; /* number of child processes */
130     extern int ray_pnidle; /* number of idle processes */
131    
132 greg 2.23 #ifndef AMBLLEN
133     #define AMBLLEN 512 /* max. ambient list length */
134     #endif
135     #define AMBWORD 12 /* average word length */
136 greg 2.12
137     typedef struct { /* rendering parameter holder */
138     int do_irrad;
139 greg 2.27 int rand_samp;
140 greg 2.12 double dstrsrc;
141     double shadthresh;
142     double shadcert;
143     int directrelay;
144     int vspretest;
145     int directvis;
146     double srcsizerat;
147     COLOR cextinction;
148     COLOR salbedo;
149     double seccg;
150     double ssampdist;
151     double specthresh;
152     double specjitter;
153     int backvis;
154     int maxdepth;
155     double minweight;
156     char ambfile[512];
157     COLOR ambval;
158     int ambvwt;
159     double ambacc;
160     int ambres;
161     int ambdiv;
162     int ambssamp;
163     int ambounce;
164     int ambincl;
165     short amblndx[AMBLLEN+1];
166     char amblval[AMBLLEN*AMBWORD];
167     } RAYPARAMS;
168    
169     #define rpambmod(p,i) ( (i)>=AMBLLEN||(p)->amblndx[i]<0 ? \
170     (char *)NULL : (p)->amblval+(p)->amblndx[i] )
171    
172     /* defined in duphead.c */
173     extern void headclean(void);
174     extern void openheader(void);
175     extern void dupheader(void);
176 schorsch 2.22 /* defined in persist.c */
177     extern void persistfile(char *pfn);
178 greg 2.12 extern void pfdetach(void);
179     extern void pfclean(void);
180     extern void pflock(int lf);
181     extern void pfhold(void);
182     extern void io_process(void);
183     /* defined in freeobjmem.c */
184     extern int free_objs(OBJECT on, OBJECT no);
185     extern void free_objmem(void);
186     /* defined in preload.c */
187     extern int load_os(OBJREC *op);
188     extern void preload_objs(void);
189     /* defined in raycalls.c */
190     extern void ray_init(char *otnm);
191     extern void ray_trace(RAY *r);
192     extern void ray_done(int freall);
193     extern void ray_save(RAYPARAMS *rp);
194     extern void ray_restore(RAYPARAMS *rp);
195     extern void ray_defaults(RAYPARAMS *rp);
196     /* defined in raypcalls.c */
197     extern void ray_pinit(char *otnm, int nproc);
198     extern void ray_psend(RAY *r);
199     extern int ray_pqueue(RAY *r);
200     extern int ray_presult(RAY *r, int poll);
201     extern void ray_pdone(int freall);
202     extern void ray_popen(int nadd);
203     extern void ray_pclose(int nsub);
204 greg 2.31 /* defined in ray_fifo.c */
205     extern int (*ray_fifo_out)(RAY *r);
206     extern int ray_fifo_in(RAY *r);
207     extern int ray_fifo_flush(void);
208 greg 2.12 /* defined in raytrace.c */
209 greg 2.25 extern int rayorigin(RAY *r, int rt, const RAY *ro, const COLOR rc);
210 greg 2.12 extern void rayclear(RAY *r);
211 greg 2.26 extern void raytrace(RAY *r);
212 greg 2.14 extern void rayhit(OBJECT *oset, RAY *r);
213 greg 2.12 extern void raycont(RAY *r);
214     extern void raytrans(RAY *r);
215     extern int rayshade(RAY *r, int mod);
216     extern void rayparticipate(RAY *r);
217 greg 2.16 extern void raytexture(RAY *r, OBJECT mod);
218 greg 2.12 extern int raymixture(RAY *r, OBJECT fore, OBJECT back, double coef);
219 greg 2.28 extern void raycontrib(double rc[3], const RAY *r, int flags);
220 greg 2.25 extern double raydist(const RAY *r, int flags);
221 greg 2.12 extern double raynormal(FVECT norm, RAY *r);
222     extern void newrayxf(RAY *r);
223     extern void flipsurface(RAY *r);
224     extern int localhit(RAY *r, CUBE *scene);
225     /* defined in renderopts.c */
226     extern int getrenderopt(int ac, char *av[]);
227     extern void print_rdefaults(void);
228     /* defined in srcdraw.c */
229     extern void drawsources(COLOR *pic[], float *zbf[],
230     int x0, int xsiz, int y0, int ysiz);
231 schorsch 2.22 extern void init_drawsources(int rad);
232     /* defined in rt/initotypes.c */
233     extern void initotypes(void);
234 greg 2.12 /* module main procedures */
235     extern void rtrace(char *fname);
236 schorsch 2.22 extern char * formstr(int f);
237 greg 2.12 extern void rview(void);
238     extern void rpict(int seq, char *pout, char *zout, char *prvr);
239 greg 1.6
240 schorsch 2.17
241     #ifdef __cplusplus
242     }
243 greg 2.12 #endif
244 schorsch 2.17 #endif /* _RAD_RAY_H_ */
245