4 #include "gamma_expansion_effect.h"
7 GammaExpansionEffect::GammaExpansionEffect()
8 : source_curve(GAMMA_LINEAR)
10 register_int("source_curve", (int *)&source_curve);
11 register_1d_texture("expansion_curve_tex", expansion_curve, EXPANSION_CURVE_SIZE);
14 std::string GammaExpansionEffect::output_fragment_shader()
16 if (source_curve == GAMMA_LINEAR) {
17 return read_file("identity.frag");
19 if (source_curve == GAMMA_sRGB) {
20 for (unsigned i = 0; i < EXPANSION_CURVE_SIZE; ++i) {
21 float x = i / (float)(EXPANSION_CURVE_SIZE - 1);
23 expansion_curve[i] = (1.0/12.92f) * x;
25 expansion_curve[i] = pow((x + 0.055) * (1.0/1.055f), 2.4);
28 invalidate_1d_texture("expansion_curve_tex");
29 return read_file("gamma_expansion_effect.frag");
31 if (source_curve == GAMMA_REC_709) { // And Rec. 601.
32 for (unsigned i = 0; i < EXPANSION_CURVE_SIZE; ++i) {
33 float x = i / (float)(EXPANSION_CURVE_SIZE - 1);
35 expansion_curve[i] = (1.0/4.5f) * x;
37 expansion_curve[i] = pow((x + 0.099) * (1.0/1.099f), 1.0f/0.45f);
40 invalidate_1d_texture("expansion_curve_tex");
41 return read_file("gamma_expansion_effect.frag");