Chain together vertex shaders, like with fragment shaders.
[movit] / gamma_compression_effect_rec709.glsl
1 // Compress to Rec. 601/Rec. 709 gamma curve.
2
3 #if 0
4
5 // if we have the lut
6 uniform sampler1D PREFIX(rec709_inverse_tex);
7
8 vec4 FUNCNAME(vec2 tc) {
9         vec4 x = LAST_INPUT(tc);
10
11         x.r = texture1D(PREFIX(rec709_inverse_tex), x.r).x;
12         x.g = texture1D(PREFIX(rec709_inverse_tex), x.g).x;
13         x.b = texture1D(PREFIX(rec709_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(4.5) * x.rgb;
25         vec3 b = vec3(1.099) * pow(x.rgb, vec3(0.45)) - vec3(0.099);
26         vec3 f = vec3(greaterThan(x.rgb, vec3(0.018)));
27
28         return vec4(mix(a, b, f), x.a); 
29 }
30  
31 #endif