1 #ifndef COLORBALANCE_AGGREGATED
2 #define COLORBALANCE_AGGREGATED
4 static char *colorbalance_get_pixel1
=
5 "vec4 colorbalance_get_pixel()\n"
7 " return gl_FragColor;\n"
10 static char *colorbalance_get_pixel2
=
11 "uniform sampler2D tex;\n"
12 "vec4 colorbalance_get_pixel()\n"
14 " return texture2D(tex, gl_TexCoord[0].st);\n"
18 static char *colorbalance_rgb_shader
=
19 "uniform vec3 colorbalance_scale;\n"
22 " gl_FragColor = colorbalance_get_pixel();\n"
23 " gl_FragColor.rgb *= colorbalance_scale;\n"
26 static char *colorbalance_yuv_shader
=
27 "uniform vec3 colorbalance_scale;\n"
30 " gl_FragColor = colorbalance_get_pixel();\n"
31 YUV_TO_RGB_FRAG("gl_FragColor")
32 " gl_FragColor.rgb *= colorbalance_scale;\n"
33 RGB_TO_YUV_FRAG("gl_FragColor")
36 static char *colorbalance_yuv_preserve_shader
=
37 "uniform vec3 colorbalance_scale;\n"
40 " gl_FragColor = colorbalance_get_pixel();\n"
41 " float y = gl_FragColor.r;\n"
42 YUV_TO_RGB_FRAG("gl_FragColor")
43 " gl_FragColor.rgb *= colorbalance_scale.rgb;\n"
44 RGB_TO_YUV_FRAG("gl_FragColor")
45 " gl_FragColor.r = y;\n"
48 #define COLORBALANCE_COMPILE(shader_stack, current_shader, aggregate_prev) \
51 shader_stack[current_shader++] = colorbalance_get_pixel1; \
53 shader_stack[current_shader++] = colorbalance_get_pixel2; \
54 if(cmodel_is_yuv(get_output()->get_color_model())) \
56 if(get_output()->get_params()->get("COLORBALANCE_PRESERVE", (int)0)) \
57 shader_stack[current_shader++] = colorbalance_yuv_preserve_shader; \
59 shader_stack[current_shader++] = colorbalance_yuv_shader; \
62 shader_stack[current_shader++] = colorbalance_rgb_shader; \
65 #define COLORBALANCE_UNIFORMS(shader) \
66 glUniform3f(glGetUniformLocation(shader, "colorbalance_scale"), \
67 get_output()->get_params()->get("COLORBALANCE_CYAN", (float)1), \
68 get_output()->get_params()->get("COLORBALANCE_MAGENTA", (float)1), \
69 get_output()->get_params()->get("COLORBALANCE_YELLOW", (float)1));