X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=footer.frag;h=8a55b01bbaa373a3a9d20d27d98ef2c80fcf1b0a;hp=04c8e7c0eb370f226181cd81b4712a718ecdec47;hb=aa1fce6c5356faa368758b15b3ad257c0f7bda0b;hpb=865a82f44545fa48a67eda605a18315d6ea15cfd diff --git a/footer.frag b/footer.frag index 04c8e7c..8a55b01 100644 --- a/footer.frag +++ b/footer.frag @@ -1,12 +1,48 @@ +// 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 SECOND_YCBCR_OUTPUT_PLANAR +#define SECOND_YCBCR_OUTPUT_PLANAR 0 +#endif + +#ifndef SECOND_YCBCR_OUTPUT_SPLIT_Y_AND_CBCR +#define SECOND_YCBCR_OUTPUT_SPLIT_Y_AND_CBCR 0 +#endif + +#ifndef SECOND_YCBCR_OUTPUT_INTERLEAVED +#define SECOND_YCBCR_OUTPUT_INTERLEAVED 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; +out vec4 Y, Cb, Cr; #elif YCBCR_OUTPUT_SPLIT_Y_AND_CBCR -out vec4 Y; -out vec4 Chroma; +out vec4 Y, Chroma; #else -out vec4 FragColor; +out vec4 FragColor; // Y'CbCr or RGBA. +#endif + +#if SECOND_YCBCR_OUTPUT_PLANAR +out vec4 Y2, Cb2, Cr2; +#elif SECOND_YCBCR_OUTPUT_SPLIT_Y_AND_CBCR +out vec4 Y2, Chroma2; +#elif SECOND_YCBCR_OUTPUT_INTERLEAVED +out vec4 YCbCr2; #endif #if YCBCR_ALSO_OUTPUT_RGBA @@ -23,6 +59,11 @@ void main() 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; @@ -34,6 +75,19 @@ void main() FragColor = color0; #endif + // Exactly the same, just with other outputs. + // (GLSL does not allow arrays of outputs.) +#if SECOND_YCBCR_OUTPUT_PLANAR + Y2 = color0.rrra; + Cb2 = color0.ggga; + Cr2 = color0.bbba; +#elif SECOND_YCBCR_OUTPUT_SPLIT_Y_AND_CBCR + Y2 = color0.rrra; + Chroma2 = color0.gbba; +#elif SECOND_YCBCR_OUTPUT_INTERLEAVED + YCbCr2 = color0; +#endif + #if YCBCR_ALSO_OUTPUT_RGBA RGBA = color1; #endif