ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/ray.h
Revision: 2.12
Committed: Sat Feb 22 02:07:29 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.11: +279 -37 lines
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# Content
1 /* RCSid: $Id$ */
2 /*
3 * ray.h - header file for routines using rays.
4 */
5
6 /* ====================================================================
7 * The Radiance Software License, Version 1.0
8 *
9 * Copyright (c) 1990 - 2002 The Regents of the University of California,
10 * through Lawrence Berkeley National Laboratory. All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in
21 * the documentation and/or other materials provided with the
22 * distribution.
23 *
24 * 3. The end-user documentation included with the redistribution,
25 * if any, must include the following acknowledgment:
26 * "This product includes Radiance software
27 * (http://radsite.lbl.gov/)
28 * developed by the Lawrence Berkeley National Laboratory
29 * (http://www.lbl.gov/)."
30 * Alternately, this acknowledgment may appear in the software itself,
31 * if and wherever such third-party acknowledgments normally appear.
32 *
33 * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
34 * and "The Regents of the University of California" must
35 * not be used to endorse or promote products derived from this
36 * software without prior written permission. For written
37 * permission, please contact [email protected].
38 *
39 * 5. Products derived from this software may not be called "Radiance",
40 * nor may "Radiance" appear in their name, without prior written
41 * permission of Lawrence Berkeley National Laboratory.
42 *
43 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
44 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
45 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
46 * DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
47 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
50 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
51 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
52 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
53 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54 * SUCH DAMAGE.
55 * ====================================================================
56 *
57 * This software consists of voluntary contributions made by many
58 * individuals on behalf of Lawrence Berkeley National Laboratory. For more
59 * information on Lawrence Berkeley National Laboratory, please see
60 * <http://www.lbl.gov/>.
61 */
62
63 #include "standard.h"
64
65 #include "octree.h"
66
67 #include "object.h"
68
69 #include "color.h"
70
71 #define MAXDIM 32 /* maximum number of dimensions */
72
73 /* ray type flags */
74 #define PRIMARY 01 /* original ray */
75 #define SHADOW 02 /* ray to light source */
76 #define REFLECTED 04 /* reflected ray */
77 #define REFRACTED 010 /* refracted (bent) ray */
78 #define TRANS 020 /* transmitted/transferred ray */
79 #define AMBIENT 040 /* ray scattered for interreflection */
80 #define SPECULAR 0100 /* ray scattered for specular */
81
82 /* reflected ray types */
83 #define RAYREFL (SHADOW|REFLECTED|AMBIENT|SPECULAR)
84
85 typedef struct ray {
86 unsigned long rno; /* unique ray number */
87 int rlvl; /* number of reflections for this ray */
88 float rweight; /* cumulative weight of this ray */
89 short rtype; /* ray type */
90 short crtype; /* cumulative ray type */
91 struct ray *parent; /* ray this originated from */
92 FVECT rorg; /* origin of ray */
93 FVECT rdir; /* normalized direction of ray */
94 double rmax; /* maximum distance (aft clipping plane) */
95 int rsrc; /* source we're aiming for */
96 OBJECT *clipset; /* set of objects currently clipped */
97 OBJECT *newcset; /* next clipset, used for transmission */
98 void (*revf)(); /* evaluation function for this ray */
99 OBJECT robj; /* intersected object number */
100 OBJREC *ro; /* intersected object (one with material) */
101 double rot; /* distance to object */
102 FVECT rop; /* intersection point */
103 FVECT ron; /* intersection surface normal */
104 double rod; /* -DOT(rdir, ron) */
105 FULLXF *rox; /* object transformation */
106 FVECT pert; /* surface normal perturbation */
107 COLOR pcol; /* pattern color */
108 COLOR rcol; /* returned ray value */
109 double rt; /* returned effective ray length */
110 COLOR cext; /* medium extinction coefficient */
111 COLOR albedo; /* medium scattering albedo */
112 float gecc; /* scattering eccentricity coefficient */
113 int *slights; /* list of lights to test for scattering */
114 } RAY;
115
116 #define rayvalue(r) (*(r)->revf)(r)
117
118 extern char VersionID[]; /* Radiance version ID string */
119
120 extern CUBE thescene; /* our scene */
121 extern OBJECT nsceneobjs; /* number of objects in our scene */
122
123 extern unsigned long raynum; /* next ray ID */
124 extern unsigned long nrays; /* total rays traced so far */
125
126 extern OBJREC Lamb; /* a Lambertian surface */
127 extern OBJREC Aftplane; /* aft clipping object */
128
129 extern void (*trace)(); /* global trace reporting callback */
130
131 extern int dimlist[]; /* dimension list for distribution */
132 extern int ndims; /* number of dimensions so far */
133 extern int samplendx; /* index for this sample */
134
135 extern int ray_savesiz; /* size of parameter save buffer */
136
137 extern int do_irrad; /* compute irradiance? */
138
139 extern double dstrsrc; /* square source distribution */
140 extern double shadthresh; /* shadow threshold */
141 extern double shadcert; /* shadow testing certainty */
142 extern int directrelay; /* number of source relays */
143 extern int vspretest; /* virtual source pretest density */
144 extern int directvis; /* light sources visible to eye? */
145 extern double srcsizerat; /* maximum source size/dist. ratio */
146
147 extern double specthresh; /* specular sampling threshold */
148 extern double specjitter; /* specular sampling jitter */
149
150 extern COLOR cextinction; /* global extinction coefficient */
151 extern COLOR salbedo; /* global scattering albedo */
152 extern double seccg; /* global scattering eccentricity */
153 extern double ssampdist; /* scatter sampling distance */
154
155 extern int backvis; /* back face visibility */
156
157 extern int maxdepth; /* maximum recursion depth */
158 extern double minweight; /* minimum ray weight */
159
160 extern char *ambfile; /* ambient file name */
161 extern COLOR ambval; /* ambient value */
162 extern int ambvwt; /* initial weight for ambient value */
163 extern double ambacc; /* ambient accuracy */
164 extern int ambres; /* ambient resolution */
165 extern int ambdiv; /* ambient divisions */
166 extern int ambssamp; /* ambient super-samples */
167 extern int ambounce; /* ambient bounces */
168 extern char *amblist[]; /* ambient include/exclude list */
169 extern int ambincl; /* include == 1, exclude == 0 */
170
171 extern int ray_pnprocs; /* number of child processes */
172 extern int ray_pnidle; /* number of idle processes */
173
174 #define AMBLLEN 128 /* max. ambient list length */
175 #define AMBWORD 8 /* average word length */
176
177 typedef struct { /* rendering parameter holder */
178 int do_irrad;
179 double dstrsrc;
180 double shadthresh;
181 double shadcert;
182 int directrelay;
183 int vspretest;
184 int directvis;
185 double srcsizerat;
186 COLOR cextinction;
187 COLOR salbedo;
188 double seccg;
189 double ssampdist;
190 double specthresh;
191 double specjitter;
192 int backvis;
193 int maxdepth;
194 double minweight;
195 char ambfile[512];
196 COLOR ambval;
197 int ambvwt;
198 double ambacc;
199 int ambres;
200 int ambdiv;
201 int ambssamp;
202 int ambounce;
203 int ambincl;
204 short amblndx[AMBLLEN+1];
205 char amblval[AMBLLEN*AMBWORD];
206 } RAYPARAMS;
207
208 #define rpambmod(p,i) ( (i)>=AMBLLEN||(p)->amblndx[i]<0 ? \
209 (char *)NULL : (p)->amblval+(p)->amblndx[i] )
210
211 #ifdef NOPROTO
212
213 extern void headclean();
214 extern void openheader();
215 extern void dupheader();
216 extern void pfdetach();
217 extern void pfclean();
218 extern void pflock();
219 extern void pfhold();
220 extern void io_process();
221 extern int free_objs();
222 extern void free_objmem();
223 extern int load_os();
224 extern void preload_objs();
225 extern void ray_init();
226 extern void ray_trace();
227 extern void ray_done();
228 extern void ray_save();
229 extern void ray_restore();
230 extern void ray_defaults();
231 extern void ray_pinit();
232 extern void ray_psend();
233 extern int ray_pqueue();
234 extern int ray_presult();
235 extern void ray_pdone();
236 extern void ray_popen();
237 extern void ray_pclose();
238 extern int rayorigin();
239 extern void rayclear();
240 extern void raytrace();
241 extern void raycont();
242 extern void raytrans();
243 extern int rayshade();
244 extern void rayparticipate();
245 extern int raymixture();
246 extern double raydist();
247 extern double raynormal();
248 extern void newrayxf();
249 extern void flipsurface();
250 extern int localhit();
251 extern int getrenderopt();
252 extern void print_rdefaults();
253 extern void drawsources();
254 extern void rtrace();
255 extern void rview();
256 extern void rpict();
257
258 #else
259 /* defined in duphead.c */
260 extern void headclean(void);
261 extern void openheader(void);
262 extern void dupheader(void);
263 extern void pfdetach(void);
264 extern void pfclean(void);
265 extern void pflock(int lf);
266 extern void pfhold(void);
267 extern void io_process(void);
268 /* defined in freeobjmem.c */
269 extern int free_objs(OBJECT on, OBJECT no);
270 extern void free_objmem(void);
271 /* defined in preload.c */
272 extern int load_os(OBJREC *op);
273 extern void preload_objs(void);
274 /* defined in raycalls.c */
275 extern void ray_init(char *otnm);
276 extern void ray_trace(RAY *r);
277 extern void ray_done(int freall);
278 extern void ray_save(RAYPARAMS *rp);
279 extern void ray_restore(RAYPARAMS *rp);
280 extern void ray_defaults(RAYPARAMS *rp);
281 /* defined in raypcalls.c */
282 extern void ray_pinit(char *otnm, int nproc);
283 extern void ray_psend(RAY *r);
284 extern int ray_pqueue(RAY *r);
285 extern int ray_presult(RAY *r, int poll);
286 extern void ray_pdone(int freall);
287 extern void ray_popen(int nadd);
288 extern void ray_pclose(int nsub);
289 /* defined in raytrace.c */
290 extern int rayorigin(RAY *r, RAY *ro, int rt, double rw);
291 extern void rayclear(RAY *r);
292 extern void raytrace(RAY *r);
293 extern void raycont(RAY *r);
294 extern void raytrans(RAY *r);
295 extern int rayshade(RAY *r, int mod);
296 extern void rayparticipate(RAY *r);
297 extern int raymixture(RAY *r, OBJECT fore, OBJECT back, double coef);
298 extern double raydist(RAY *r, int flags);
299 extern double raynormal(FVECT norm, RAY *r);
300 extern void newrayxf(RAY *r);
301 extern void flipsurface(RAY *r);
302 extern int localhit(RAY *r, CUBE *scene);
303 /* defined in renderopts.c */
304 extern int getrenderopt(int ac, char *av[]);
305 extern void print_rdefaults(void);
306 /* defined in srcdraw.c */
307 extern void drawsources(COLOR *pic[], float *zbf[],
308 int x0, int xsiz, int y0, int ysiz);
309 /* module main procedures */
310 extern void rtrace(char *fname);
311 extern void rview(void);
312 extern void rpict(int seq, char *pout, char *zout, char *prvr);
313
314 #endif