+// 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
+
void main()
{
INPUT();
void cs_output(uvec2 coord, vec4 val)
{
- imageStore(outbuf, ivec2(coord), val);
+ cs_output(ivec2(coord), val);
}
void cs_output(ivec2 coord, vec4 val)
{
+#if SQUARE_ROOT_TRANSFORMATION
+ // Make sure we don't give negative values to sqrt.
+ val.rgb = sqrt(max(val.rgb, 0.0));
+#endif
imageStore(outbuf, coord, val);
}