X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=footer.frag;h=339ef7bbb335887fd36f4d209f03d3dfb6247618;hp=e41e83c093ac03be573069fd2a37595e87810fda;hb=f216b7bef5a968c89f6fc78e83cc26a91e504a8a;hpb=6eb839737216564bcaf4645b7ebf6ea9efc2da09 diff --git a/footer.frag b/footer.frag index e41e83c..339ef7b 100644 --- a/footer.frag +++ b/footer.frag @@ -1,4 +1,64 @@ +// GLSL is pickier than the C++ preprocessor in if-testing for undefined +// tokens; do some fixups here to keep it happy. + +#ifndef YCBCR_OUTPUT_PLANAR +#define YCBCR_OUTPUT_PLANAR 0 +#endif + +#ifndef YCBCR_OUTPUT_SPLIT_Y_AND_CBCR +#define YCBCR_OUTPUT_SPLIT_Y_AND_CBCR 0 +#endif + +#ifndef YCBCR_ALSO_OUTPUT_RGBA +#define YCBCR_ALSO_OUTPUT_RGBA 0 +#endif + +#ifndef SQUARE_ROOT_TRANSFORMATION +#define SQUARE_ROOT_TRANSFORMATION 0 +#endif + +#if YCBCR_OUTPUT_PLANAR +out vec4 Y; +out vec4 Cb; +out vec4 Cr; +#elif YCBCR_OUTPUT_SPLIT_Y_AND_CBCR +out vec4 Y; +out vec4 Chroma; +#else +out vec4 FragColor; +#endif + +#if YCBCR_ALSO_OUTPUT_RGBA +out vec4 RGBA; +#endif + void main() { - gl_FragColor = INPUT(tc); +#if YCBCR_ALSO_OUTPUT_RGBA + vec4 color[2] = INPUT(tc); + vec4 color0 = color[0]; + vec4 color1 = color[1]; +#else + vec4 color0 = INPUT(tc); +#endif + +#if SQUARE_ROOT_TRANSFORMATION + // Make sure we don't give negative values to sqrt. + color0.rgb = sqrt(max(color0.rgb, 0.0)); +#endif + +#if YCBCR_OUTPUT_PLANAR + Y = color0.rrra; + Cb = color0.ggga; + Cr = color0.bbba; +#elif YCBCR_OUTPUT_SPLIT_Y_AND_CBCR + Y = color0.rrra; + Chroma = color0.gbba; +#else + FragColor = color0; +#endif + +#if YCBCR_ALSO_OUTPUT_RGBA + RGBA = color1; +#endif }