+#include <assert.h>
+
#include "gamma_expansion_effect.h"
#include "util.h"
std::string GammaExpansionEffect::output_glsl()
{
- return read_file("todo.glsl");
+ switch (source_curve) {
+ case GAMMA_sRGB:
+ return read_file("gamma_expansion_effect_srgb.glsl");
+ case GAMMA_REC_709: // and GAMMA_REC_601
+ // Not implemented yet.
+ assert(false);
+ default:
+ assert(false);
+ }
}
--- /dev/null
+// Expand sRGB gamma curve.
+
+#if 0
+
+// if we have the lut
+uniform sampler1D PREFIX(srgb_tex);
+
+vec4 FUNCNAME(vec2 tc) {
+ vec4 x = LAST_INPUT(tc);
+
+ x.r = texture1D(PREFIX(srgb_tex), x.r).x;
+ x.g = texture1D(PREFIX(srgb_tex), x.g).x;
+ x.b = texture1D(PREFIX(srgb_tex), x.b).x;
+
+ return x;
+}
+
+#else
+
+// use arithmetic (slow)
+vec4 FUNCNAME(vec2 tc) {
+ vec4 x = LAST_INPUT(tc);
+
+ vec3 a = x.rgb * vec3(1.0/12.92);
+ vec3 b = pow((x.rgb + vec3(0.055)) * vec3(1.0/1.055), vec3(2.4));
+ vec3 f = vec3(greaterThan(x.rgb, vec3(0.04045)));
+
+ return vec4(mix(a, b, f), x.a);
+}
+
+#endif