Allow storing values in intermediate framebuffers as sqrt(x).
[movit] / footer.frag
1 // GLSL is pickier than the C++ preprocessor in if-testing for undefined
2 // tokens; do some fixups here to keep it happy.
3
4 #ifndef YCBCR_OUTPUT_PLANAR
5 #define YCBCR_OUTPUT_PLANAR 0
6 #endif
7
8 #ifndef YCBCR_OUTPUT_SPLIT_Y_AND_CBCR
9 #define YCBCR_OUTPUT_SPLIT_Y_AND_CBCR 0
10 #endif
11
12 #ifndef YCBCR_ALSO_OUTPUT_RGBA
13 #define YCBCR_ALSO_OUTPUT_RGBA 0
14 #endif
15
16 #ifndef SQUARE_ROOT_TRANSFORMATION
17 #define SQUARE_ROOT_TRANSFORMATION 0
18 #endif
19
20 #if YCBCR_OUTPUT_PLANAR
21 out vec4 Y;
22 out vec4 Cb;
23 out vec4 Cr;
24 #elif YCBCR_OUTPUT_SPLIT_Y_AND_CBCR
25 out vec4 Y;
26 out vec4 Chroma;
27 #else
28 out vec4 FragColor;
29 #endif
30
31 #if YCBCR_ALSO_OUTPUT_RGBA
32 out vec4 RGBA;
33 #endif
34
35 void main()
36 {
37 #if YCBCR_ALSO_OUTPUT_RGBA
38         vec4 color[2] = INPUT(tc);
39         vec4 color0 = color[0];
40         vec4 color1 = color[1];
41 #else
42         vec4 color0 = INPUT(tc);
43 #endif
44
45 #if SQUARE_ROOT_TRANSFORMATION
46         // Make sure we don't give negative values to sqrt.
47         color0.rgb = sqrt(max(color0.rgb, 0.0));
48 #endif
49
50 #if YCBCR_OUTPUT_PLANAR
51         Y = color0.rrra;
52         Cb = color0.ggga;
53         Cr = color0.bbba;
54 #elif YCBCR_OUTPUT_SPLIT_Y_AND_CBCR
55         Y = color0.rrra;
56         Chroma = color0.gbba;
57 #else
58         FragColor = color0;
59 #endif
60
61 #if YCBCR_ALSO_OUTPUT_RGBA
62         RGBA = color1;
63 #endif
64 }