]> git.sesse.net Git - movit/blob - gamma_expansion_effect_rec709.frag
Kill the vertex shader system; it is too complicated to get it right until we have...
[movit] / gamma_expansion_effect_rec709.frag
1 // Expand Rec. 601/Rec. 709 gamma curve.
2
3 #if 0
4
5 // if we have the lut
6 uniform sampler1D PREFIX(rec709_tex);
7
8 vec4 FUNCNAME(vec2 tc) {
9         vec4 x = LAST_INPUT(tc);
10
11         x.r = texture1D(PREFIX(rec709_tex), x.r).x;
12         x.g = texture1D(PREFIX(rec709_tex), x.g).x;
13         x.b = texture1D(PREFIX(rec709_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 = x.rgb * vec3(1.0/4.500);
25         vec3 b = pow((x.rgb + vec3(0.099)) * vec3(1.0/1.099), vec3(1.0/0.45));
26         vec3 f = vec3(greaterThan(x.rgb, vec3(0.081)));
27
28         return vec4(mix(a, b, f), x.a); 
29 }
30  
31 #endif