r1008: pt_BR translation update
[cinelerra_cv/mob.git] / plugins / colorbalance / aggregated.h
blob99f33ba5779be840d1df4f2683b2e6da8afed967
1 #ifndef COLORBALANCE_AGGREGATED
2 #define COLORBALANCE_AGGREGATED
4 static char *colorbalance_get_pixel1 =
5 "vec4 colorbalance_get_pixel()\n"
6 "{\n"
7 " return gl_FragColor;\n"
8 "}\n";
10 static char *colorbalance_get_pixel2 =
11 "uniform sampler2D tex;\n"
12 "vec4 colorbalance_get_pixel()\n"
13 "{\n"
14 " return texture2D(tex, gl_TexCoord[0].st);\n"
15 "}\n";
18 static char *colorbalance_rgb_shader =
19 "uniform vec3 colorbalance_scale;\n"
20 "void main()\n"
21 "{\n"
22 " gl_FragColor = colorbalance_get_pixel();\n"
23 " gl_FragColor.rgb *= colorbalance_scale;\n"
24 "}\n";
26 static char *colorbalance_yuv_shader =
27 "uniform vec3 colorbalance_scale;\n"
28 "void main()\n"
29 "{\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")
34 "}\n";
36 static char *colorbalance_yuv_preserve_shader =
37 "uniform vec3 colorbalance_scale;\n"
38 "void main()\n"
39 "{\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"
46 "}\n";
48 #define COLORBALANCE_COMPILE(shader_stack, current_shader, aggregate_prev) \
49 { \
50 if(aggregate_prev) \
51 shader_stack[current_shader++] = colorbalance_get_pixel1; \
52 else \
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; \
58 else \
59 shader_stack[current_shader++] = colorbalance_yuv_shader; \
60 } \
61 else \
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));
71 #endif