]> git.sesse.net Git - movit/blob - gamma_expansion_effect.frag
Do not bother with unbinding vertex attributes; that is automatically done when we...
[movit] / gamma_expansion_effect.frag
1 // Expand gamma curve.
2
3 // Implicit uniforms:
4 // uniform float PREFIX(linear_scale);
5 // uniform float PREFIX(c0), PREFIX(c1), PREFIX(c2), PREFIX(c3), PREFIX(c4);
6 // uniform float PREFIX(beta);
7
8 vec4 FUNCNAME(vec2 tc) {
9         vec4 x = INPUT(tc);
10
11         vec3 a = x.rgb * PREFIX(linear_scale);
12
13         // Fourth-order polynomial approximation to pow(). See the .cpp file for details.
14         vec3 b = PREFIX(c0) + (PREFIX(c1) + (PREFIX(c2) + (PREFIX(c3) + PREFIX(c4) * x.rgb) * x.rgb) * x.rgb) * x.rgb;
15
16         vec3 f = vec3(greaterThan(x.rgb, vec3(PREFIX(beta))));
17         x = vec4(mix(a, b, f), x.a);
18
19         return x;
20 }