File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 37
37
#if !defined (DIRECTXTK)
38
38
#define DIRECTXTK
39
39
40
+ /*
41
+ https://github.com/microsoft/DirectX-Specs
42
+ */
43
+
40
44
// (Approximate) sRGB to linear
41
45
float4 SRGBToLinearEst (float4 ColorMap)
42
46
{
43
47
#if defined (_USELINEARLIGHTING_)
44
- ColorMap.rgb = pow (abs (ColorMap.rgb) , 2.2 );
48
+ ColorMap.rgb = (ColorMap <= 0.04045 ) ? ColorMap / 12.92 : pow ((ColorMap + 0.055 ) / 1.055 , 2.4 );
45
49
#endif
46
50
return ColorMap;
47
51
}
50
54
void LinearToSRGBEst (inout float4 Color)
51
55
{
52
56
#if defined (_USELINEARLIGHTING_)
53
- Color.rgb = pow ( abs ( Color.rgb) , 1.0 / 2.2 ) ;
57
+ Color = ( Color <= 0.0031308 ) ? 12.92 * Color : 1.055 * pow (Color , 1.0 / 2.4 ) - 0.055 ;
54
58
#endif
55
59
}
56
60
Original file line number Diff line number Diff line change 37
37
#if !defined (DIRECTXTK)
38
38
#define DIRECTXTK
39
39
40
+ /*
41
+ https://github.com/microsoft/DirectX-Specs
42
+ */
43
+
40
44
// (Approximate) sRGB to linear
41
45
float4 SRGBToLinearEst (float4 ColorMap)
42
46
{
43
47
#if defined (_USELINEARLIGHTING_)
44
- ColorMap.rgb = pow (abs (ColorMap.rgb) , 2.2 );
48
+ ColorMap.rgb = (ColorMap <= 0.04045 ) ? ColorMap / 12.92 : pow ((ColorMap + 0.055 ) / 1.055 , 2.4 );
45
49
#endif
46
50
return ColorMap;
47
51
}
50
54
void LinearToSRGBEst (inout float4 Color)
51
55
{
52
56
#if defined (_USELINEARLIGHTING_)
53
- Color.rgb = pow ( abs ( Color.rgb) , 1.0 / 2.2 ) ;
57
+ Color = ( Color <= 0.0031308 ) ? 12.92 * Color : 1.055 * pow (Color , 1.0 / 2.4 ) - 0.055 ;
54
58
#endif
55
59
}
56
60
You can’t perform that action at this time.
0 commit comments