Chain together vertex shaders, like with fragment shaders.
[movit] / gamma_compression_effect_srgb.frag
1 // Compress to sRGB gamma curve.
2
3 #if 0
4
5 // if we have the lut
6 uniform sampler1D PREFIX(srgb_inverse_tex);
7
8 vec4 FUNCNAME(vec2 tc) {
9         vec4 x = LAST_INPUT(tc);
10
11         x.r = texture1D(PREFIX(srgb_inverse_tex), x.r).x;
12         x.g = texture1D(PREFIX(srgb_inverse_tex), x.g).x;
13         x.b = texture1D(PREFIX(srgb_inverse_tex), x.b).x;
14
15         return x;
16 }
17
18 #else
19
20 // use arithmetic (slow)
21 vec4 FUNCNAME(vec2 tc) {
22         vec4 x = LAST_INPUT(tc);
23
24         vec3 a = vec3(12.92) * x.rgb;
25         vec3 b = vec3(1.055) * pow(x.rgb, vec3(1.0/2.4)) - vec3(0.055);
26         vec3 f = vec3(greaterThan(x.rgb, vec3(0.0031308)));
27
28         return vec4(mix(a, b, f), x.a); 
29 }
30  
31 #endif