X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=footer.comp;h=c4d1305be8512bcb1c77e17b3e24ee2266dc5686;hp=3ece901eb00e8de9fe4f1200101a19162b2b08fc;hb=9527105a4958fa20f8d87d719a26b00cb000c0e8;hpb=5e771df1523ea3f7926c0b5a115c29d134c53f11 diff --git a/footer.comp b/footer.comp index 3ece901..c4d1305 100644 --- a/footer.comp +++ b/footer.comp @@ -1,3 +1,14 @@ +// GLSL is pickier than the C++ preprocessor in if-testing for undefined +// tokens; do some fixups here to keep it happy. + +#ifndef SQUARE_ROOT_TRANSFORMATION +#define SQUARE_ROOT_TRANSFORMATION 0 +#endif + +#ifndef FLIP_ORIGIN +#define FLIP_ORIGIN 0 +#endif + void main() { INPUT(); @@ -10,10 +21,23 @@ vec4 tex2D(sampler2D s, vec2 coord) void cs_output(uvec2 coord, vec4 val) { - imageStore(outbuf, ivec2(coord), val); + cs_output(ivec2(coord), val); } void cs_output(ivec2 coord, vec4 val) { + // Run the value through any preprocessing steps we might have. + CS_OUTPUT_VAL = val; + val = CS_POSTPROC(vec2(0.0, 0.0)); + +#if SQUARE_ROOT_TRANSFORMATION + // Make sure we don't give negative values to sqrt. + val.rgb = sqrt(max(val.rgb, 0.0)); +#endif + +#if FLIP_ORIGIN + coord.y = imageSize(outbuf).y - coord.y - 1; +#endif + imageStore(outbuf, coord, val); }