Back to index

radiance  4R0+20100331
ambient.h
Go to the documentation of this file.
00001 /* RCSid $Id: ambient.h,v 2.16 2005/09/23 19:04:53 greg Exp $ */
00002 /*
00003  * Common definitions for interreflection routines.
00004  *
00005  * Include after ray.h
00006  */
00007 #ifndef _RAD_AMBIENT_H_
00008 #define _RAD_AMBIENT_H_
00009 #ifdef __cplusplus
00010 extern "C" {
00011 #endif
00012 
00013 /*
00014  * Since we've defined our vectors as float below to save space,
00015  * watch out for changes in the definitions of VCOPY() and DOT()
00016  * and don't pass these vectors to fvect routines.
00017  */
00018 typedef struct ambrec {
00019        unsigned long  latick;      /* last accessed tick */
00020        float  pos[3];              /* position in space */
00021        float  dir[3];              /* normal direction */
00022        int    lvl;          /* recursion level of parent ray */
00023        float  weight;              /* weight of parent ray */
00024        float  rad;          /* validity radius */
00025        COLOR  val;          /* computed ambient value */
00026        float  gpos[3];             /* gradient wrt. position */
00027        float  gdir[3];             /* gradient wrt. direction */
00028        struct ambrec  *next;       /* next in list */
00029 }  AMBVAL;                  /* ambient value */
00030 
00031 typedef struct ambtree {
00032        AMBVAL *alist;              /* ambient value list */
00033        struct ambtree       *kid;  /* 8 child nodes */
00034 }  AMBTREE;                 /* ambient octree */
00035 
00036 typedef struct {
00037        COLOR  v;            /* division sum (partial) */
00038        float  r;            /* 1/distance sum */
00039        float  k;            /* variance for this division */
00040        int  n;                     /* number of subsamples */
00041        short  t, p;         /* theta, phi indices */
00042 }  AMBSAMP;          /* ambient sample division */
00043 
00044 typedef struct {
00045        FVECT  ux, uy, uz;   /* x, y and z axis directions */
00046        COLOR  acoef;        /* division contribution coefficient */
00047        int    ns;           /* number of super-samples */
00048        short  nt, np;              /* number of theta and phi directions */
00049 }  AMBHEMI;          /* ambient sample hemisphere */
00050 
00051 extern double  maxarad;            /* maximum ambient radius */
00052 extern double  minarad;            /* minimum ambient radius */
00053 
00054 #ifndef AVGREFL
00055 #define  AVGREFL     0.5    /* assumed average reflectance */
00056 #endif
00057 
00058 #define  AMBVALSIZ   75     /* number of bytes in portable AMBVAL struct */
00059 #define  AMBMAGIC    557    /* magic number for ambient value files */
00060 #define  AMBFMT             "Radiance_ambval"    /* format id string */
00061 
00062                                    /* defined in ambient.c */
00063 extern void   setambres(int ar);
00064 extern void   setambacc(double newa);
00065 extern void   setambient(void);
00066 extern void   multambient(COLOR aval, RAY *r, FVECT nrm);
00067 extern void   ambdone(void);
00068 extern void   ambnotify(OBJECT obj);
00069 extern double sumambient(COLOR acol, RAY *r, FVECT rn, int al,
00070                             AMBTREE *at, FVECT c0, double s);
00071 extern double makeambient(COLOR acol, RAY *r, FVECT rn, int al);
00072 extern void   extambient(COLOR cr, AMBVAL *ap, FVECT pv, FVECT nv);
00073 extern int    ambsync(void);
00074                                    /* defined in ambcomp.c */
00075 extern double doambient(COLOR acol, RAY *r, double wt,
00076                                    FVECT pg, FVECT dg);
00077 extern void   inithemi(AMBHEMI *hp, COLOR ac, RAY *r, double wt);
00078 extern int    divsample(AMBSAMP *dp, AMBHEMI *h, RAY *r);
00079 extern void   comperrs(AMBSAMP *da, AMBHEMI *hp);
00080 extern void   posgradient(FVECT gv, AMBSAMP *da, AMBHEMI *hp);
00081 extern void   dirgradient(FVECT gv, AMBSAMP *da, AMBHEMI *hp);
00082                                    /* defined in ambio.c */
00083 extern void   putambmagic(FILE *fp);
00084 extern int    hasambmagic(FILE *fp);
00085 extern int    writambval(AMBVAL *av, FILE *fp);
00086 extern int    ambvalOK(AMBVAL *av);
00087 extern int    readambval(AMBVAL *av, FILE *fp);
00088                                    /* defined in lookamb.c */
00089 extern void   lookamb(FILE *fp);
00090 extern void   writamb(FILE *fp);
00091 
00092 
00093 #ifdef __cplusplus
00094 }
00095 #endif
00096 #endif /* _RAD_AMBIENT_H_ */
00097