Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 2baf891

Browse files
committed
Added even faster but incorrect sRGB/Linear funcs for mobiles
1 parent 10dbd84 commit 2baf891

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

PostProcessing/Shaders/Colors.hlsl

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@
2525
#define DEFAULT_MAX_PQ 100.0
2626
#endif
2727

28+
#ifndef USE_VERY_FAST_SRGB
29+
#if defined(SHADER_API_MOBILE)
30+
#define USE_VERY_FAST_SRGB 1
31+
#else
32+
#define USE_VERY_FAST_SRGB 0
33+
#endif
34+
#endif
35+
2836
#ifndef USE_FAST_SRGB
29-
#ifdef SHADER_API_MOBILE
37+
#if defined(SHADER_API_CONSOLE)
3038
#define USE_FAST_SRGB 1
3139
#else
3240
#define USE_FAST_SRGB 0
@@ -150,7 +158,9 @@ float3 PQToLinear(float3 x)
150158
//
151159
half SRGBToLinear(half c)
152160
{
153-
#if USE_FAST_SRGB
161+
#if USE_VERY_FAST_SRGB
162+
return c * c;
163+
#elif USE_FAST_SRGB
154164
return c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878);
155165
#else
156166
half linearRGBLo = c / 12.92;
@@ -162,7 +172,9 @@ half SRGBToLinear(half c)
162172

163173
half3 SRGBToLinear(half3 c)
164174
{
165-
#if USE_FAST_SRGB
175+
#if USE_VERY_FAST_SRGB
176+
return c * c;
177+
#elif USE_FAST_SRGB
166178
return c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878);
167179
#else
168180
half3 linearRGBLo = c / 12.92;
@@ -179,7 +191,9 @@ half4 SRGBToLinear(half4 c)
179191

180192
half LinearToSRGB(half c)
181193
{
182-
#if USE_FAST_SRGB
194+
#if USE_VERY_FAST_SRGB
195+
return sqrt(c);
196+
#elif USE_FAST_SRGB
183197
return max(1.055 * PositivePow(c, 0.416666667) - 0.055, 0.0);
184198
#else
185199
half sRGBLo = c * 12.92;
@@ -191,7 +205,9 @@ half LinearToSRGB(half c)
191205

192206
half3 LinearToSRGB(half3 c)
193207
{
194-
#if USE_FAST_SRGB
208+
#if USE_VERY_FAST_SRGB
209+
return sqrt(c);
210+
#elif USE_FAST_SRGB
195211
return max(1.055 * PositivePow(c, 0.416666667) - 0.055, 0.0);
196212
#else
197213
half3 sRGBLo = c * 12.92;

0 commit comments

Comments
 (0)