--- ray/src/common/color.h 1991/07/17 11:52:25 1.12 +++ ray/src/common/color.h 1994/08/17 11:07:56 2.8 @@ -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" */ @@ -41,15 +41,61 @@ typedef float COLOR[3]; /* red, green, blue */ #define multcolor(c1,c2) ((c1)[0]*=(c2)[0],(c1)[1]*=(c2)[1],(c1)[2]*=(c2)[2]) #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 CIE_x_r 0.670 /* standard NTSC primaries */ +#define CIE_y_r 0.330 +#define CIE_x_g 0.210 +#define CIE_y_g 0.710 +#define CIE_x_b 0.140 +#define CIE_y_b 0.080 +#define CIE_x_w 0.3333 /* use true white */ +#define CIE_y_w 0.3333 #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 CIE_x_r 0.640 /* nominal CRT primaries */ +#define CIE_y_r 0.330 +#define CIE_x_g 0.290 +#define CIE_y_g 0.600 +#define CIE_x_b 0.150 +#define CIE_y_b 0.060 +#define CIE_x_w 0.3333 /* use true white */ +#define CIE_y_w 0.3333 #endif -#define luminance(col) (470. * bright(col)) +#define CIE_D ( CIE_x_r*(CIE_y_g - CIE_y_b) + \ + CIE_x_g*(CIE_y_b - CIE_y_r) + \ + CIE_x_b*(CIE_y_r - CIE_y_g) ) +#define CIE_C_rD ( (1./CIE_y_w) * \ + ( CIE_x_w*(CIE_y_g - CIE_y_b) - \ + CIE_y_w*(CIE_x_g - CIE_x_b) + \ + CIE_x_g*CIE_y_b - CIE_x_b*CIE_y_g ) ) +#define CIE_C_gD ( (1./CIE_y_w) * \ + ( CIE_x_w*(CIE_y_b - CIE_y_r) - \ + CIE_y_w*(CIE_x_b - CIE_x_r) - \ + CIE_x_r*CIE_y_b + CIE_x_b*CIE_y_r ) ) +#define CIE_C_bD ( (1./CIE_y_w) * \ + ( CIE_x_w*(CIE_y_r - CIE_y_g) - \ + CIE_y_w*(CIE_x_r - CIE_x_g) + \ + CIE_x_r*CIE_y_g - CIE_x_g*CIE_y_r ) ) +#define CIE_rf (CIE_y_r*CIE_C_rD/CIE_D) +#define CIE_gf (CIE_y_g*CIE_C_gD/CIE_D) +#define CIE_bf (CIE_y_b*CIE_C_bD/CIE_D) + +#define bright(col) (CIE_rf*(col)[RED]+CIE_gf*(col)[GRN]+CIE_bf*(col)[BLU]) +#define normbright(c) ( ( (long)(CIE_rf*256.+.5)*(c)[RED] + \ + (long)(CIE_gf*256.+.5)*(c)[GRN] + \ + (long)(CIE_bf*256.+.5)*(c)[BLU] ) >> 8 ) + + /* 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,11 +109,6 @@ 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" @@ -94,4 +135,6 @@ typedef float COLOR[3]; /* red, green, blue */ #define fputcolcor(cc,fp) fprintf(fp,"%s %f %f %f\n",COLCORSTR, \ (cc)[RED],(cc)[GRN],(cc)[BLU]) -extern double ldexp(), atof(); +#ifdef DCL_ATOF +extern double atof(), ldexp(), frexp(); +#endif