|
@@ -1,15 +1,5 @@
|
|
|
// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/
|
|
|
|
|
|
-// These encodings should have the same integer values as THREE.LinearEncoding, THREE.sRGBEncoding, etc...
|
|
|
-#define ENCODING_Linear 3000
|
|
|
-#define ENCODING_sRGB 3001
|
|
|
-#define ENCODING_RGBE 3002
|
|
|
-#define ENCODING_LogLuv 3003
|
|
|
-#define ENCODING_RGBM7 3004
|
|
|
-#define ENCODING_RGBM16 3005
|
|
|
-#define ENCODING_RGBD 3006
|
|
|
-#define ENCODING_Gamma 3007
|
|
|
-
|
|
|
vec4 LinearToLinear( in vec4 value ) {
|
|
|
return value;
|
|
|
}
|
|
@@ -55,17 +45,14 @@ vec4 RGBDToLinear( in vec4 value, in float maxRange ) {
|
|
|
vec4 LinearToRGBD( in vec4 value, in float maxRange ) {
|
|
|
float maxRGB = max( value.x, max( value.g, value.b ) );
|
|
|
float D = max( maxRange / maxRGB, 1.0 );
|
|
|
- D = saturate( floor( D ) / 255.0 );
|
|
|
+ D = min( floor( D ) / 255.0, 1.0 );
|
|
|
return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );
|
|
|
}
|
|
|
|
|
|
// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html
|
|
|
|
|
|
// M matrix, for encoding
|
|
|
-const mat3 cLogLuvM = mat3(
|
|
|
- 0.2209, 0.3390, 0.4184,
|
|
|
- 0.1138, 0.6780, 0.7319,
|
|
|
- 0.0102, 0.1130, 0.2969);
|
|
|
+const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );
|
|
|
vec4 LinearToLogLuv( in vec4 value ) {
|
|
|
vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;
|
|
|
Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));
|
|
@@ -78,10 +65,7 @@ vec4 LinearToLogLuv( in vec4 value ) {
|
|
|
}
|
|
|
|
|
|
// Inverse M matrix, for decoding
|
|
|
-const mat3 cLogLuvInverseM = mat3(
|
|
|
- 6.0014, -2.7008, -1.7996,
|
|
|
- -1.3320, 3.1029, -5.7721,
|
|
|
- 0.3008, -1.0882, 5.6268);
|
|
|
+const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );
|
|
|
vec4 LogLuvToLinear( in vec4 value ) {
|
|
|
float Le = value.z * 255.0 + value.w;
|
|
|
vec3 Xp_Y_XYZp;
|