--- ray/src/rt/ray.h 1997/03/07 16:53:02 2.11 +++ ray/src/rt/ray.h 2003/05/09 22:18:03 2.16 @@ -1,15 +1,14 @@ -/* Copyright (c) 1995 Regents of the University of California */ - -/* SCCSid "$SunId$ LBL" */ - +/* RCSid $Id: ray.h,v 2.16 2003/05/09 22:18:03 greg Exp $ */ /* * ray.h - header file for routines using rays. - * - * 8/7/85 */ +#include "copyright.h" + #include "standard.h" +#include "octree.h" + #include "object.h" #include "color.h" @@ -30,43 +29,237 @@ typedef struct ray { unsigned long rno; /* unique ray number */ - int rlvl; /* number of reflections for this ray */ - float rweight; /* cumulative weight of this ray */ - short rtype; /* ray type */ - short crtype; /* cumulative ray type */ + int rlvl; /* number of reflections for this ray */ + float rweight; /* cumulative weight of this ray */ + short rtype; /* ray type */ + short crtype; /* cumulative ray type */ struct ray *parent; /* ray this originated from */ - FVECT rorg; /* origin of ray */ - FVECT rdir; /* normalized direction of ray */ - double rmax; /* maximum distance (aft clipping plane) */ - int rsrc; /* source we're aiming for */ - OBJECT *clipset; /* set of objects currently clipped */ - OBJECT *newcset; /* next clipset, used for transmission */ - int (*revf)(); /* evaluation function for this ray */ + FVECT rorg; /* origin of ray */ + FVECT rdir; /* normalized direction of ray */ + double rmax; /* maximum distance (aft clipping plane) */ + int rsrc; /* source we're aiming for */ + OBJECT *clipset; /* set of objects currently clipped */ + OBJECT *newcset; /* next clipset, used for transmission */ + void (*revf)(); /* evaluation function for this ray */ + void (*hitf)(); /* custom hit test for this traversal */ OBJECT robj; /* intersected object number */ - OBJREC *ro; /* intersected object (one with material) */ - double rot; /* distance to object */ - FVECT rop; /* intersection point */ - FVECT ron; /* intersection surface normal */ - double rod; /* -DOT(rdir, ron) */ - FULLXF *rox; /* object transformation */ - FVECT pert; /* surface normal perturbation */ - COLOR pcol; /* pattern color */ - COLOR rcol; /* returned ray value */ - double rt; /* returned effective ray length */ - COLOR cext; /* medium extinction coefficient */ - COLOR albedo; /* medium scattering albedo */ - float gecc; /* scattering eccentricity coefficient */ - int *slights; /* list of lights to test for scattering */ + OBJREC *ro; /* intersected object (one with material) */ + double rot; /* distance to object */ + FVECT rop; /* intersection point */ + FVECT ron; /* intersection surface normal */ + double rod; /* -DOT(rdir, ron) */ + FULLXF *rox; /* object transformation */ + FLOAT uv[2]; /* local coordinates */ + FVECT pert; /* surface normal perturbation */ + COLOR pcol; /* pattern color */ + COLOR rcol; /* returned ray value */ + double rt; /* returned effective ray length */ + COLOR cext; /* medium extinction coefficient */ + COLOR albedo; /* medium scattering albedo */ + float gecc; /* scattering eccentricity coefficient */ + int *slights; /* list of lights to test for scattering */ } RAY; -extern int raytrace(); +#define rayvalue(r) (*(r)->revf)(r) -extern double raynormal(); +extern char VersionID[]; /* Radiance version ID string */ -extern double raydist(); +extern CUBE thescene; /* our scene */ +extern OBJECT nsceneobjs; /* number of objects in our scene */ -extern int dimlist[]; /* dimension list for distribution */ -extern int ndims; /* number of dimensions so far */ -extern int samplendx; /* index for this sample */ +extern unsigned long raynum; /* next ray ID */ +extern unsigned long nrays; /* total rays traced so far */ -#define rayvalue(r) (*(r)->revf)(r) +extern OBJREC Lamb; /* a Lambertian surface */ +extern OBJREC Aftplane; /* aft clipping object */ + +extern void (*trace)(); /* global trace reporting callback */ + +extern int dimlist[]; /* dimension list for distribution */ +extern int ndims; /* number of dimensions so far */ +extern int samplendx; /* index for this sample */ + +extern int ray_savesiz; /* size of parameter save buffer */ + +extern int do_irrad; /* compute irradiance? */ + +extern double dstrsrc; /* square source distribution */ +extern double shadthresh; /* shadow threshold */ +extern double shadcert; /* shadow testing certainty */ +extern int directrelay; /* number of source relays */ +extern int vspretest; /* virtual source pretest density */ +extern int directvis; /* light sources visible to eye? */ +extern double srcsizerat; /* maximum source size/dist. ratio */ + +extern double specthresh; /* specular sampling threshold */ +extern double specjitter; /* specular sampling jitter */ + +extern COLOR cextinction; /* global extinction coefficient */ +extern COLOR salbedo; /* global scattering albedo */ +extern double seccg; /* global scattering eccentricity */ +extern double ssampdist; /* scatter sampling distance */ + +extern int backvis; /* back face visibility */ + +extern int maxdepth; /* maximum recursion depth */ +extern double minweight; /* minimum ray weight */ + +extern char *ambfile; /* ambient file name */ +extern COLOR ambval; /* ambient value */ +extern int ambvwt; /* initial weight for ambient value */ +extern double ambacc; /* ambient accuracy */ +extern int ambres; /* ambient resolution */ +extern int ambdiv; /* ambient divisions */ +extern int ambssamp; /* ambient super-samples */ +extern int ambounce; /* ambient bounces */ +extern char *amblist[]; /* ambient include/exclude list */ +extern int ambincl; /* include == 1, exclude == 0 */ + +extern int ray_pnprocs; /* number of child processes */ +extern int ray_pnidle; /* number of idle processes */ + +#define AMBLLEN 128 /* max. ambient list length */ +#define AMBWORD 8 /* average word length */ + +typedef struct { /* rendering parameter holder */ + int do_irrad; + double dstrsrc; + double shadthresh; + double shadcert; + int directrelay; + int vspretest; + int directvis; + double srcsizerat; + COLOR cextinction; + COLOR salbedo; + double seccg; + double ssampdist; + double specthresh; + double specjitter; + int backvis; + int maxdepth; + double minweight; + char ambfile[512]; + COLOR ambval; + int ambvwt; + double ambacc; + int ambres; + int ambdiv; + int ambssamp; + int ambounce; + int ambincl; + short amblndx[AMBLLEN+1]; + char amblval[AMBLLEN*AMBWORD]; +} RAYPARAMS; + +#define rpambmod(p,i) ( (i)>=AMBLLEN||(p)->amblndx[i]<0 ? \ + (char *)NULL : (p)->amblval+(p)->amblndx[i] ) + +#ifdef NOPROTO + +extern void headclean(); +extern void openheader(); +extern void dupheader(); +extern void pfdetach(); +extern void pfclean(); +extern void pflock(); +extern void pfhold(); +extern void io_process(); +extern int free_objs(); +extern void free_objmem(); +extern int load_os(); +extern void preload_objs(); +extern void ray_init(); +extern void ray_trace(); +extern void ray_done(); +extern void ray_save(); +extern void ray_restore(); +extern void ray_defaults(); +extern void ray_pinit(); +extern void ray_psend(); +extern int ray_pqueue(); +extern int ray_presult(); +extern void ray_pdone(); +extern void ray_popen(); +extern void ray_pclose(); +extern int rayorigin(); +extern void rayclear(); +extern void raytrace(); +extern void rayhit(); +extern void raycont(); +extern void raytrans(); +extern int rayshade(); +extern void rayparticipate(); +extern void raytexture(); +extern int raymixture(); +extern double raydist(); +extern double raynormal(); +extern void newrayxf(); +extern void flipsurface(); +extern int localhit(); +extern int getrenderopt(); +extern void print_rdefaults(); +extern void drawsources(); +extern void rtrace(); +extern void rview(); +extern void rpict(); + +#else + /* defined in duphead.c */ +extern void headclean(void); +extern void openheader(void); +extern void dupheader(void); +extern void pfdetach(void); +extern void pfclean(void); +extern void pflock(int lf); +extern void pfhold(void); +extern void io_process(void); + /* defined in freeobjmem.c */ +extern int free_objs(OBJECT on, OBJECT no); +extern void free_objmem(void); + /* defined in preload.c */ +extern int load_os(OBJREC *op); +extern void preload_objs(void); + /* defined in raycalls.c */ +extern void ray_init(char *otnm); +extern void ray_trace(RAY *r); +extern void ray_done(int freall); +extern void ray_save(RAYPARAMS *rp); +extern void ray_restore(RAYPARAMS *rp); +extern void ray_defaults(RAYPARAMS *rp); + /* defined in raypcalls.c */ +extern void ray_pinit(char *otnm, int nproc); +extern void ray_psend(RAY *r); +extern int ray_pqueue(RAY *r); +extern int ray_presult(RAY *r, int poll); +extern void ray_pdone(int freall); +extern void ray_popen(int nadd); +extern void ray_pclose(int nsub); + /* defined in raytrace.c */ +extern int rayorigin(RAY *r, RAY *ro, int rt, double rw); +extern void rayclear(RAY *r); +extern void raytrace(RAY *r); +extern void rayhit(OBJECT *oset, RAY *r); +extern void raycont(RAY *r); +extern void raytrans(RAY *r); +extern int rayshade(RAY *r, int mod); +extern void rayparticipate(RAY *r); +extern void raytexture(RAY *r, OBJECT mod); +extern int raymixture(RAY *r, OBJECT fore, OBJECT back, double coef); +extern double raydist(RAY *r, int flags); +extern double raynormal(FVECT norm, RAY *r); +extern void newrayxf(RAY *r); +extern void flipsurface(RAY *r); +extern int localhit(RAY *r, CUBE *scene); + /* defined in renderopts.c */ +extern int getrenderopt(int ac, char *av[]); +extern void print_rdefaults(void); + /* defined in srcdraw.c */ +extern void drawsources(COLOR *pic[], float *zbf[], + int x0, int xsiz, int y0, int ysiz); + /* module main procedures */ +extern void rtrace(char *fname); +extern void rview(void); +extern void rpict(int seq, char *pout, char *zout, char *prvr); + +#endif