ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/ambient.h
Revision: 2.18
Committed: Thu Sep 22 02:15:56 2011 UTC (12 years, 7 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad4R1
Changes since 2.17: +2 -2 lines
Log Message:
Minor optimizations

File Contents

# User Rev Content
1 greg 2.18 /* RCSid $Id: ambient.h,v 2.17 2010/10/05 18:05:23 greg Exp $ */
2 greg 1.1 /*
3     * Common definitions for interreflection routines.
4 greg 2.7 *
5     * Include after ray.h
6     */
7 schorsch 2.9 #ifndef _RAD_AMBIENT_H_
8     #define _RAD_AMBIENT_H_
9     #ifdef __cplusplus
10     extern "C" {
11     #endif
12 greg 1.1
13     /*
14     * Since we've defined our vectors as float below to save space,
15     * watch out for changes in the definitions of VCOPY() and DOT()
16     * and don't pass these vectors to fvect routines.
17     */
18     typedef struct ambrec {
19 greg 2.18 struct ambrec *next; /* next in list */
20 greg 2.5 unsigned long latick; /* last accessed tick */
21 greg 1.1 float pos[3]; /* position in space */
22     float dir[3]; /* normal direction */
23 greg 2.14 int lvl; /* recursion level of parent ray */
24 greg 1.1 float weight; /* weight of parent ray */
25     float rad; /* validity radius */
26     COLOR val; /* computed ambient value */
27     float gpos[3]; /* gradient wrt. position */
28     float gdir[3]; /* gradient wrt. direction */
29     } AMBVAL; /* ambient value */
30    
31 greg 2.7 typedef struct ambtree {
32     AMBVAL *alist; /* ambient value list */
33     struct ambtree *kid; /* 8 child nodes */
34     } AMBTREE; /* ambient octree */
35    
36     typedef struct {
37 greg 2.15 COLOR v; /* division sum (partial) */
38 greg 2.7 float r; /* 1/distance sum */
39     float k; /* variance for this division */
40 greg 2.17 int n; /* number of subsamples */
41     unsigned short t, p; /* theta, phi indices */
42 greg 2.7 } AMBSAMP; /* ambient sample division */
43    
44     typedef struct {
45 greg 2.16 FVECT ux, uy, uz; /* x, y and z axis directions */
46 greg 2.15 COLOR acoef; /* division contribution coefficient */
47 greg 2.16 int ns; /* number of super-samples */
48 greg 2.17 int nt, np; /* number of theta and phi directions */
49 greg 2.7 } AMBHEMI; /* ambient sample hemisphere */
50    
51 greg 1.1 extern double maxarad; /* maximum ambient radius */
52     extern double minarad; /* minimum ambient radius */
53    
54 greg 2.11 #ifndef AVGREFL
55 greg 1.2 #define AVGREFL 0.5 /* assumed average reflectance */
56 greg 2.11 #endif
57 greg 2.2
58     #define AMBVALSIZ 75 /* number of bytes in portable AMBVAL struct */
59 greg 2.4 #define AMBMAGIC 557 /* magic number for ambient value files */
60 greg 2.3 #define AMBFMT "Radiance_ambval" /* format id string */
61 greg 2.7
62     /* defined in ambient.c */
63     extern void setambres(int ar);
64     extern void setambacc(double newa);
65     extern void setambient(void);
66 greg 2.12 extern void multambient(COLOR aval, RAY *r, FVECT nrm);
67 greg 2.7 extern void ambdone(void);
68     extern void ambnotify(OBJECT obj);
69 greg 2.15 extern double sumambient(COLOR acol, RAY *r, FVECT rn, int al,
70 greg 2.7 AMBTREE *at, FVECT c0, double s);
71 greg 2.15 extern double makeambient(COLOR acol, RAY *r, FVECT rn, int al);
72 greg 2.7 extern void extambient(COLOR cr, AMBVAL *ap, FVECT pv, FVECT nv);
73     extern int ambsync(void);
74 greg 2.12 /* defined in ambcomp.c */
75 greg 2.15 extern double doambient(COLOR acol, RAY *r, double wt,
76 greg 2.12 FVECT pg, FVECT dg);
77 greg 2.15 extern void inithemi(AMBHEMI *hp, COLOR ac, RAY *r, double wt);
78 greg 2.12 extern int divsample(AMBSAMP *dp, AMBHEMI *h, RAY *r);
79     extern void comperrs(AMBSAMP *da, AMBHEMI *hp);
80     extern void posgradient(FVECT gv, AMBSAMP *da, AMBHEMI *hp);
81     extern void dirgradient(FVECT gv, AMBSAMP *da, AMBHEMI *hp);
82 greg 2.7 /* defined in ambio.c */
83     extern void putambmagic(FILE *fp);
84     extern int hasambmagic(FILE *fp);
85     extern int writambval(AMBVAL *av, FILE *fp);
86     extern int ambvalOK(AMBVAL *av);
87     extern int readambval(AMBVAL *av, FILE *fp);
88     /* defined in lookamb.c */
89     extern void lookamb(FILE *fp);
90     extern void writamb(FILE *fp);
91    
92 schorsch 2.9
93     #ifdef __cplusplus
94     }
95 greg 2.7 #endif
96 schorsch 2.9 #endif /* _RAD_AMBIENT_H_ */
97