-
Notifications
You must be signed in to change notification settings - Fork 9
/
footer.comp
46 lines (37 loc) · 1.03 KB
/
footer.comp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// 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();
}
vec4 tex2D(sampler2D s, vec2 coord)
{
return texture(s, coord);
}
void cs_output(uvec2 coord, vec4 val)
{
cs_output(ivec2(coord), val);
}
void cs_output(ivec2 coord, vec4 val)
{
// Run the value through any postprocessing steps we might have.
// Note that we need to give in the actual coordinates, since the
// effect could have multiple (non-compute) inputs, and would also
// be allowed to make effects based on the texture coordinate alone.
CS_OUTPUT_VAL = val;
val = CS_POSTPROC(NORMALIZE_TEXTURE_COORDS(coord));
#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(tex_outbuf).y - coord.y - 1;
#endif
imageStore(tex_outbuf, coord, val);
}