--- ray/src/rt/ray.h 2009/12/15 18:21:53 2.33 +++ ray/src/rt/ray.h 2024/08/21 20:42:20 2.56 @@ -1,4 +1,4 @@ -/* RCSid $Id: ray.h,v 2.33 2009/12/15 18:21:53 greg Exp $ */ +/* RCSid $Id: ray.h,v 2.56 2024/08/21 20:42:20 greg Exp $ */ /* * ray.h - header file for routines using rays. */ @@ -9,28 +9,35 @@ #include "octree.h" #include "object.h" #include "color.h" +#include "pmapparm.h" #ifdef __cplusplus extern "C" { #endif #ifndef RNUMBER -#define RNUMBER unsigned long /* ray counter (>= sizeof pointer) */ +#define RNUMBER size_t /* ray counter (>= sizeof pointer) */ #endif -#define MAXDIM 32 /* maximum number of dimensions */ +#define MAXDIM 32 /* maximum number of sampling dimensions */ /* ray type flags */ #define PRIMARY 01 /* original ray */ -#define SHADOW 02 /* ray to light source */ +#define RSHADOW 02 /* reflected ray to light source */ #define REFLECTED 04 /* reflected ray */ #define REFRACTED 010 /* refracted (bent) ray */ #define TRANS 020 /* transmitted/transferred ray */ -#define AMBIENT 040 /* ray scattered for interreflection */ -#define SPECULAR 0100 /* ray scattered for specular */ +#define RAMBIENT 040 /* reflected diffuse interreflection */ +#define RSPECULAR 0100 /* reflected specular */ +#define TSHADOW 0200 /* transmitted shadow */ +#define TAMBIENT 0400 /* transmitted ambient */ +#define TSPECULAR 01000 /* transmitted specular */ +#define SHADOW (RSHADOW|TSHADOW) +#define AMBIENT (RAMBIENT|TAMBIENT) +#define SPECULAR (RSPECULAR|TSPECULAR) /* reflected ray types */ -#define RAYREFL (SHADOW|REFLECTED|AMBIENT|SPECULAR) +#define RAYREFL (RSHADOW|REFLECTED|RAMBIENT|RSPECULAR) /* Arrange so double's come first for optimal alignment */ /* Pointers and long's come second for 64-bit mode */ @@ -45,7 +52,8 @@ typedef struct ray { RREAL rod; /* -DOT(rdir, ron) */ RREAL uv[2]; /* local coordinates */ FVECT pert; /* surface normal perturbation */ - RREAL rt; /* returned effective ray length */ + RREAL rmt; /* returned mirrored ray length */ + RREAL rxt; /* returned unmirrored ray length */ const struct ray *parent; /* ray this originated from */ OBJECT *clipset; /* set of objects currently clipped */ OBJECT *newcset; /* next clipset, used for transmission */ @@ -55,41 +63,49 @@ typedef struct ray { FULLXF *rox; /* object transformation */ int *slights; /* list of lights to test for scattering */ RNUMBER rno; /* unique ray number */ - int rlvl; /* number of reflections for this ray */ + OBJECT robj; /* intersected object number */ int rsrc; /* source we're aiming for */ float rweight; /* cumulative weight (for termination) */ - COLOR rcoef; /* contribution coefficient w.r.t. parent */ - COLOR pcol; /* pattern color */ - COLOR rcol; /* returned radiance value */ + float gecc; /* scattering eccentricity coefficient */ + SCOLOR rcoef; /* contribution coefficient w.r.t. parent */ + SCOLOR pcol; /* pattern color */ + SCOLOR mcol; /* mirrored color contribution */ + SCOLOR rcol; /* returned radiance value */ COLOR cext; /* medium extinction coefficient */ COLOR albedo; /* medium scattering albedo */ - float gecc; /* scattering eccentricity coefficient */ - OBJECT robj; /* intersected object number */ + short rflips; /* surface orientation has been reversed */ + short rlvl; /* number of reflections for this ray */ short rtype; /* ray type */ short crtype; /* cumulative ray type */ } RAY; #define rayvalue(r) (*(r)->revf)(r) -extern char VersionID[]; /* Radiance version ID string */ +#define thrudir(r,v) ((r)->rod > 0 ^ DOT((r)->ron,v) > 0) +#define raydistance(r) (pbright((r)->mcol) > 0.5*pbright((r)->rcol) ? \ + (r)->rmt : (r)->rxt) + +#define rayreorient(r) if ((r)->rflips & 1) flipsurface(r); else + +extern char VersionID[]; /* Radiance version ID string */ +extern char RFeatureList[]; /* newline-separated feature list */ + extern CUBE thescene; /* our scene */ extern OBJECT nsceneobjs; /* number of objects in our scene */ -extern unsigned long raynum; /* next ray ID */ -extern unsigned long nrays; /* total rays traced so far */ +extern RNUMBER raynum; /* next ray ID */ +extern RNUMBER nrays; /* total rays traced so far */ extern OBJREC Lamb; /* a Lambertian surface */ extern OBJREC Aftplane; /* aft clipping object */ -extern void (*trace)(); /* global trace reporting callback */ +extern void (*trace)(RAY*); /* 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 int rand_samp; /* pure Monte Carlo sampling? */ @@ -164,6 +180,9 @@ typedef struct { /* rendering parameter holder */ int ambincl; short amblndx[AMBLLEN+1]; char amblval[AMBLLEN*AMBWORD]; + + /* PMAP: photon mapping parameters */ + PhotonMapParams pmapParams [NUM_PMAP_TYPES]; } RAYPARAMS; #define rpambmod(p,i) ( (i)>=AMBLLEN||(p)->amblndx[i]<0 ? \ @@ -174,7 +193,7 @@ extern void headclean(void); extern void openheader(void); extern void dupheader(void); /* defined in persist.c */ -extern void persistfile(char *pfn); +extern void persistfile(char *pfn); extern void pfdetach(void); extern void pfclean(void); extern void pflock(int lf); @@ -186,6 +205,9 @@ extern void free_objmem(void); /* defined in preload.c */ extern int load_os(OBJREC *op); extern void preload_objs(void); +extern char *shm_boundary; +extern void cow_memshare(void); +extern void cow_doneshare(void); /* defined in raycalls.c */ extern void ray_init(char *otnm); extern void ray_trace(RAY *r); @@ -206,37 +228,45 @@ extern int (*ray_fifo_out)(RAY *r); extern int ray_fifo_in(RAY *r); extern int ray_fifo_flush(void); /* defined in raytrace.c */ -extern int rayorigin(RAY *r, int rt, const RAY *ro, const COLOR rc); +extern int rayorigin(RAY *r, int rt, const RAY *ro, const SCOLOR rc); extern void rayclear(RAY *r); extern void raytrace(RAY *r); +extern int rayreject(OBJREC *o, RAY *r, double t, double rod); extern void rayhit(OBJECT *oset, RAY *r); extern void raycont(RAY *r); extern void raytrans(RAY *r); +extern int raytirrad(OBJREC *m, 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 void raycontrib(double rc[3], const RAY *r, int flags); +extern void raycontrib(SCOLOR rc, const RAY *r, int flags); extern double raydist(const 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 feature_status(int ac, char *av[]); extern int getrenderopt(int ac, char *av[]); extern void print_rdefaults(void); /* defined in srcdraw.c */ -extern void drawsources(COLOR *pic[], float *zbf[], +extern void init_drawsources(int rad); +extern void drawsources(COLORV *pic[], RGBPRIMP primp, float *zbf[], int x0, int xsiz, int y0, int ysiz); -extern void init_drawsources(int rad); /* defined in rt/initotypes.c */ -extern void initotypes(void); +extern void initotypes(void); /* module main procedures */ extern void rtrace(char *fname, int nproc); -extern char *formstr(int f); +extern const char *formstr(int f); extern void rview(void); extern void rpict(int seq, char *pout, char *zout, char *prvr); +#ifdef __FAST_MATH__ +#define checknorm(vn) (void)normalize(vn) +#else +#define checknorm(vn) +#endif #ifdef __cplusplus }