]> git.sesse.net Git - movit/commitdiff
Add lift/gamma/gain GLSL code. Completely black output, due to lack of uniform setting.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 1 Oct 2012 17:23:38 +0000 (19:23 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 1 Oct 2012 17:23:38 +0000 (19:23 +0200)
lift_gamma_gain_effect.cpp
lift_gamma_gain_effect.glsl [new file with mode: 0644]

index eef04d54a4bd2e5141159adec62eaf073267899e..149cb4463931dc9836df4360dd35a2480ea3d0fd 100644 (file)
@@ -15,5 +15,5 @@ LiftGammaGainEffect::LiftGammaGainEffect()
 
 std::string LiftGammaGainEffect::output_glsl()
 {
 
 std::string LiftGammaGainEffect::output_glsl()
 {
-       return read_file("todo.glsl");
+       return read_file("lift_gamma_gain_effect.glsl");
 }
 }
diff --git a/lift_gamma_gain_effect.glsl b/lift_gamma_gain_effect.glsl
new file mode 100644 (file)
index 0000000..17437fb
--- /dev/null
@@ -0,0 +1,21 @@
+// Standard lift/gamma/gain color correction tools.
+//
+// We do lift in a nonlinear (gamma-2.2) space since that looks a lot better
+// than in linear (blacks stay a lot closer to black). The two others don't
+// really care; they are (sans some constants) commutative with the x^2.2
+// operation.
+
+// These are calculated in the host code to save some arithmetic.
+uniform vec3 PREFIX(gain_pow_inv_gamma), PREFIX(inv_gamma_22);
+
+vec4 FUNCNAME(vec2 tc) {
+       vec4 x = LAST_INPUT(tc);
+
+       // do lift in nonlinear space (the others don't care)
+       x.rgb = pow(x.rgb, vec3(1.0/2.2));
+       x.rgb += PREFIX(lift) * (vec3(1) - x.rgb);
+       x.rgb = pow(x.rgb, PREFIX(inv_gamma_22));
+       x.rgb *= PREFIX(gain_pow_inv_gamma);
+
+       return x;
+}