--- ray/src/rt/ambient.h 1992/08/10 08:46:38 2.4 +++ ray/src/rt/ambient.h 2023/11/15 18:02:52 2.27 @@ -1,43 +1,73 @@ -/* Copyright (c) 1991 Regents of the University of California */ - -/* SCCSid "$SunId$ LBL" */ - +/* RCSid $Id: ambient.h,v 2.27 2023/11/15 18:02:52 greg Exp $ */ /* * Common definitions for interreflection routines. + * + * Include after ray.h */ +#ifndef _RAD_AMBIENT_H_ +#define _RAD_AMBIENT_H_ +#ifdef __cplusplus +extern "C" { +#endif + /* - * Since we've defined our vectors as float below to save space, - * watch out for changes in the definitions of VCOPY() and DOT() - * and don't pass these vectors to fvect routines. + * Normal and u-vector directions encoded using dircode.c */ typedef struct ambrec { + struct ambrec *next; /* next in list */ float pos[3]; /* position in space */ - float dir[3]; /* normal direction */ - int lvl; /* recursion level of parent ray */ + int32 ndir; /* encoded surface normal */ + int32 udir; /* u-vector direction */ + short lvl; /* recursion level of parent ray */ float weight; /* weight of parent ray */ - float rad; /* validity radius */ - COLOR val; /* computed ambient value */ - float gpos[3]; /* gradient wrt. position */ - float gdir[3]; /* gradient wrt. direction */ - struct ambrec *next; /* next in list */ + float rad[2]; /* anisotropic radii (rad[0] <= rad[1]) */ + float gpos[2]; /* (u,v) gradient wrt. position */ + float gdir[2]; /* (u,v) gradient wrt. direction */ + uint32 corral; /* potential light leak direction flags */ + SCOLOR val; /* computed indirect irradiance (last!) */ } AMBVAL; /* ambient value */ -extern COLOR ambval; /* global ambient component */ -extern double ambacc; /* ambient accuracy */ -extern int ambres; /* ambient resolution */ -extern int ambdiv; /* number of divisions for calculation */ -extern int ambssamp; /* number of super-samples */ -extern int ambounce; /* number of ambient bounces */ -extern char *amblist[]; /* ambient include/exclude list */ -extern int ambincl; /* include == 1, exclude == 0 */ +typedef struct ambtree { + AMBVAL *alist; /* ambient value list */ + struct ambtree *kid; /* 8 child nodes */ +} AMBTREE; /* ambient octree */ + extern double maxarad; /* maximum ambient radius */ extern double minarad; /* minimum ambient radius */ -extern double sumambient(), doambient(), makeambient(); - +#ifndef AVGREFL #define AVGREFL 0.5 /* assumed average reflectance */ +#endif -#define AMBVALSIZ 75 /* number of bytes in portable AMBVAL struct */ -#define AMBMAGIC 557 /* magic number for ambient value files */ +#define AMBVALSIZ (64+AMB_CNDX[3]) /* number of bytes in portable AMBVAL */ +#define AMBMAGIC 561 /* magic number for ambient value file */ #define AMBFMT "Radiance_ambval" /* format id string */ + + /* defined in ambient.c */ +extern void setambres(int ar); +extern void setambacc(double newa); +extern void setambient(void); +extern void multambient(SCOLOR aval, RAY *r, FVECT nrm); +extern void ambdone(void); +extern void ambnotify(OBJECT obj); +extern int ambsync(void); + /* defined in ambcomp.c */ +extern int doambient(SCOLOR acol, RAY *r, double wt, + FVECT uv[2], float rad[2], + float gpos[2], float gdir[2], uint32 *crlp); + /* defined in ambio.c */ +extern int *AMB_CNDX; /* open ambient file RGBE indices */ +extern float *AMB_WLPART; /* open ambient file spectral range */ +extern int amb_headline(char *hl, void *p); +extern void putambmagic(FILE *fp); +extern int hasambmagic(FILE *fp); +extern int writambval(AMBVAL *av, FILE *fp); +extern int readambval(AMBVAL *av, FILE *fp); +extern int ambvalOK(AMBVAL *av); + +#ifdef __cplusplus +} +#endif +#endif /* _RAD_AMBIENT_H_ */ +