]> git.tdb.fi Git - libs/gl.git/blob - tests/glsl/unsigned_int.glsl
Rearrange postprocessor creation code in SequenceBuilder
[libs/gl.git] / tests / glsl / unsigned_int.glsl
1 uniform sampler2D tex;
2 vec2 hammersley(uint i, uint count)
3 {
4         float y = bitfieldReverse(i)*2.3283064e-10;
5         return vec2(float(i)/count, y);
6 }
7 const uint sample_count = 128;
8
9 #pragma MSP stage(vertex)
10 layout(location=0) in vec4 position;
11 void main()
12 {
13         gl_Position = position;
14         out vec2 texcoord = position.xy*0.5+0.5;
15 }
16
17 #pragma MSP stage(fragment)
18 layout(location=0) out vec4 frag_color;
19 void main()
20 {
21         vec4 sum = vec4(0.0);
22         for(int i=0; i<sample_count; ++i)
23                 sum += texture(tex, texcoord+pow(hammersley(i, sample_count), vec2(2.0)));
24         frag_color = sum/sample_count;
25 }
26
27 /* Expected output: vertex
28 layout(location=0) in vec4 position;
29 layout(location=0) out vec2 texcoord;
30 void main()
31 {
32         gl_Position = position;
33         texcoord = position.xy*0.5+0.5;
34 }
35 */
36
37 /* Expected output: fragment
38 layout(location=0, binding=71) uniform sampler2D tex;
39 layout(location=0) out vec4 frag_color;
40 layout(location=0) in vec2 texcoord;
41 void main()
42 {
43         vec4 sum = vec4(0.0);
44         for(int i=0; uint(i)<128u; ++i)
45         {
46                 uint i_1 = uint(i);
47                 sum += texture(tex, texcoord+pow(vec2(float(i_1)/128.0, float(bitfieldReverse(i_1))*2.3283064e-10), vec2(2.0)));
48         }
49         frag_color = sum/128.0;
50 }
51 */