--- ray/src/common/bsdf_m.h 2011/04/08 18:13:48 3.4 +++ ray/src/common/bsdf_m.h 2018/01/05 21:00:24 3.9 @@ -1,4 +1,4 @@ -/* RCSid $Id: bsdf_m.h,v 3.4 2011/04/08 18:13:48 greg Exp $ */ +/* RCSid $Id: bsdf_m.h,v 3.9 2018/01/05 21:00:24 greg Exp $ */ /* * bsdf_m.h * @@ -33,6 +33,7 @@ typedef struct { b_vecf *ob_vec; /* get output vector from index */ b_ndxf *ob_ndx; /* get output index from vector */ b_ohmf *ob_ohm; /* get output proj. SA for index */ + C_CHROMA *chroma; /* chromaticity data */ float bsdf[1]; /* scattering data (extends struct) */ } SDMat; @@ -44,10 +45,11 @@ typedef struct { #define mBSDF_outndx(b,v) (*(b)->ob_ndx)(v,(b)->ob_priv) #define mBSDF_outohm(b,o) (*(b)->ob_ohm)(o,(b)->ob_priv) #define mBSDF_value(b,i,o) (b)->bsdf[(o)*(b)->ninc + (i)] +#define mBSDF_chroma(b,i,o) (b)->chroma[(o)*(b)->ninc + (i)] /* Holder for cumulative distribution (sum of BSDF * projSA) */ -typedef struct { - SD_CDIST_BASE; /* base fields; must come first */ +typedef struct SDMatCDst_s { + SD_CDIST_BASE(SDMatCDst_s); /* base fields; must come first */ int indx; /* incident angle index */ void *ob_priv; /* private data for generator */ b_vecf *ob_vec; /* outbound vector generator */ @@ -61,7 +63,60 @@ extern SDError SDloadMtx(SDData *sd, ezxml_t wtl); #endif /* Our matrix handling routines */ -extern SDFunc SDhandleMtx; +extern const SDFunc SDhandleMtx; + +/******** Klems basis declarations for more intimate access ********/ + +#define MAXLATS 46 /* maximum number of latitudes */ + +/* BSDF angle specification */ +typedef struct { + char name[64]; /* basis name */ + int nangles; /* total number of directions */ + struct { + float tmin; /* starting theta */ + int nphis; /* number of phis (0 term) */ + } lat[MAXLATS+1]; /* latitudes */ +} ANGLE_BASIS; + +#define MAXABASES 7 /* limit on defined bases */ + +extern ANGLE_BASIS abase_list[MAXABASES]; + +extern int nabases; /* current number of defined bases */ + +extern C_COLOR mtx_RGB_prim[3]; /* matrix RGB primaries */ +extern float mtx_RGB_coef[3]; /* corresponding Y coefficients */ + +/* Get color or grayscale value for BSDF in the given directions */ +extern int mBSDF_color(float coef[], const SDMat *b, int i, int o); + +/* Get vector for this angle basis index (front exiting) */ +extern b_vecf fo_getvec; + +/* Get index corresponding to the given vector (front exiting) */ +extern b_ndxf fo_getndx; + +/* Get projected solid angle for this angle basis index (universal) */ +extern b_ohmf io_getohm; + +/* Get vector for this angle basis index (back incident) */ +extern b_vecf bi_getvec; + +/* Get index corresponding to the vector (back incident) */ +extern b_ndxf bi_getndx; + +/* Get vector for this angle basis index (back exiting) */ +extern b_vecf bo_getvec; + +/* Get index corresponding to the vector (back exiting) */ +extern b_ndxf bo_getndx; + +/* Get vector for this angle basis index (front incident) */ +extern b_vecf fi_getvec; + +/* Get index corresponding to the vector (front incident) */ +extern b_ndxf fi_getndx; #ifdef __cplusplus }