]> git.sesse.net Git - movit/blob - footer.comp
Fix an issue where we'd add an unneeded bounce for mipmaps in some cases.
[movit] / footer.comp
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 SQUARE_ROOT_TRANSFORMATION
5 #define SQUARE_ROOT_TRANSFORMATION 0
6 #endif
7
8 #ifndef FLIP_ORIGIN
9 #define FLIP_ORIGIN 0
10 #endif
11
12 void main()
13 {
14         INPUT();
15 }
16
17 vec4 tex2D(sampler2D s, vec2 coord)
18 {
19         return texture(s, coord);
20 }
21
22 void cs_output(uvec2 coord, vec4 val)
23 {
24         cs_output(ivec2(coord), val);
25 }
26
27 void cs_output(ivec2 coord, vec4 val)
28 {
29         // Run the value through any postprocessing steps we might have.
30         // Note that we need to give in the actual coordinates, since the
31         // effect could have multiple (non-compute) inputs, and would also
32         // be allowed to make effects based on the texture coordinate alone.
33         CS_OUTPUT_VAL = val;
34         val = CS_POSTPROC(NORMALIZE_TEXTURE_COORDS(coord));
35
36 #if SQUARE_ROOT_TRANSFORMATION
37         // Make sure we don't give negative values to sqrt.
38         val.rgb = sqrt(max(val.rgb, 0.0));
39 #endif
40
41 #if FLIP_ORIGIN
42         coord.y = imageSize(tex_outbuf).y - coord.y - 1;
43 #endif
44
45         imageStore(tex_outbuf, coord, val);
46 }