--- ray/src/common/color.h 1991/03/18 09:32:49 1.9 +++ ray/src/common/color.h 1993/06/04 14:51:41 2.5 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ /* SCCSid "$SunId$ LBL" */ @@ -42,14 +42,23 @@ typedef float COLOR[3]; /* red, green, blue */ #ifdef NTSC #define bright(col) (.295*(col)[RED]+.636*(col)[GRN]+.070*(col)[BLU]) -#define normbright(c) (int)((74L*(c)[RED]+164L*(c)[GRN]+18L*(c)[BLU])/256) +#define normbright(c) (int)((74L*(c)[RED]+164L*(c)[GRN]+18L*(c)[BLU])>>8) #else #define bright(col) (.263*(col)[RED]+.655*(col)[GRN]+.082*(col)[BLU]) -#define normbright(c) (int)((67L*(c)[RED]+168L*(c)[GRN]+21L*(c)[BLU])/256) +#define normbright(c) (int)((67L*(c)[RED]+168L*(c)[GRN]+21L*(c)[BLU])>>8) #endif -#define luminance(col) (683.0 * bright(col)) + /* luminous efficacies over visible spectrum */ +#define MAXEFFICACY 683. /* defined maximum at 550 nm */ +#define WHTEFFICACY 179. /* uniform white light */ +#define D65EFFICACY 203. /* standard illuminant D65 */ +#define INCEFFICACY 160. /* illuminant A (incand.) */ +#define SUNEFFICACY 208. /* illuminant B (solar dir.) */ +#define SKYEFFICACY D65EFFICACY /* skylight */ +#define DAYEFFICACY D65EFFICACY /* combined sky and solar */ +#define luminance(col) (WHTEFFICACY * bright(col)) + #define intens(col) ( (col)[0] > (col)[1] \ ? (col)[0] > (col)[2] ? (col)[0] : (col)[2] \ : (col)[1] > (col)[2] ? (col)[1] : (col)[2] ) @@ -63,32 +72,28 @@ typedef float COLOR[3]; /* red, green, blue */ #define WHTCOLR {128,128,128,COLXS+1} #define BLKCOLR {0,0,0,0} - /* definitions for resolution header */ -#define XDECR 1 -#define YDECR 2 -#define YMAJOR 4 + /* picture format identifier */ +#define COLRFMT "32-bit_rle_rgbe" /* macros for exposures */ #define EXPOSSTR "EXPOSURE=" -#define EXPOSSTRL 9 -#define isexpos(hl) (!strncmp(hl,EXPOSSTR,EXPOSSTRL)) -#define exposval(hl) atof((hl)+EXPOSSTRL) +#define LEXPOSSTR 9 +#define isexpos(hl) (!strncmp(hl,EXPOSSTR,LEXPOSSTR)) +#define exposval(hl) atof((hl)+LEXPOSSTR) #define fputexpos(ex,fp) fprintf(fp,"%s%e\n",EXPOSSTR,ex) /* macros for pixel aspect ratios */ #define ASPECTSTR "PIXASPECT=" -#define ASPECTSTRL 10 -#define isaspect(hl) (!strncmp(hl,ASPECTSTR,ASPECTSTRL)) -#define aspectval(hl) atof((hl)+ASPECTSTRL) +#define LASPECTSTR 10 +#define isaspect(hl) (!strncmp(hl,ASPECTSTR,LASPECTSTR)) +#define aspectval(hl) atof((hl)+LASPECTSTR) #define fputaspect(pa,fp) fprintf(fp,"%s%f\n",ASPECTSTR,pa) /* macros for color correction */ #define COLCORSTR "COLORCORR=" -#define COLCORSTRL 10 -#define iscolcor(hl) (!strncmp(hl,COLCORSTR,COLCORSTRL)) -#define colcorval(cc,hl) sscanf(hl+COLCORSTRL,"%f %f %f", \ +#define LCOLCORSTR 10 +#define iscolcor(hl) (!strncmp(hl,COLCORSTR,LCOLCORSTR)) +#define colcorval(cc,hl) sscanf(hl+LCOLCORSTR,"%f %f %f", \ &(cc)[RED],&(cc)[GRN],&(cc)[BLU]) #define fputcolcor(cc,fp) fprintf(fp,"%s %f %f %f\n",COLCORSTR, \ (cc)[RED],(cc)[GRN],(cc)[BLU]) - -extern double ldexp(), atof();