+
+
+ /* store direction */
+ if( deluxel )
+ {
+ if(normalizeDeluxemap)
+ {
+ if(!VectorNormalize(deluxel, direction))
+ VectorClear(direction);
+ }
+ else
+ {
+ if(deluxel[3])
+ {
+ VectorScale(deluxel, 1 / deluxel[3], direction);
+ // NOTE:
+ // if the light was scaled down due to it being too bright...
+ // we need to reduce the directionality so ADDING light can't
+ // make stuff DARKER!
+ if(colorMultiplier < 1)
+ VectorScale(direction, colorMultiplier, direction);
+ // TODO find out the best renderer equation for this
+ }
+ else
+ VectorClear(direction);
+ }
+
+ /* normalize average light direction */
+ //if(direction[0] != 0 || direction[1] != 0 || direction[2] != 0)
+ {
+ /* encode [-1,1] in [0,255] */
+ for( i = 0; i < 3; i++ )
+ {
+ temp = (direction[ i ] + 1.0f) * 127.5f;
+ if( temp < 0 )
+ deluxeBytes[ i ] = 0;
+ else if( temp > 255 )
+ deluxeBytes[ i ] = 255;
+ else
+ deluxeBytes[ i ] = temp;
+ }
+ }
+ }
+}
+
+void ColorToBytes( const float *color, byte *colorBytes, float scale )
+{
+ ColorToBytesDeluxe(color, colorBytes, scale, NULL, NULL);