ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/ray.h
Revision: 2.28
Committed: Tue Jun 21 15:06:50 2005 UTC (18 years, 10 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1
Changes since 2.27: +2 -2 lines
Log Message:
Fixed bugs in black glass transmission and source weight computation

File Contents

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