Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uniform sampler2D ReductionTexture;
- uniform vec2 TexelSize;
- uniform int Iteration;
- uniform int Mode; // 0 == initalize, 1 == reduce
- smooth VSData vec2 TexPos;
- uniform mat4 Orthographic;
- #ifdef VERTEX_SHADER
- in vec2 Vertex;
- void main()
- {
- vec4 result = Orthographic * vec4(Vertex, 0, 1);
- gl_Position = result;
- TexPos = Vertex;
- }
- #elif defined FRAGMENT_SHADER
- out vec4 FsColor;
- void main()
- {
- ivec2 frag = ivec2(TexPos);
- if(Mode == 0)
- {
- FsColor = texelFetch(ReductionTexture, frag, 0);
- return;
- }
- frag *= 2;
- vec4 max = texelFetch(ReductionTexture, frag, 0);
- vec4 test = texelFetch(ReductionTexture, frag + ivec2(0, 1), 0);
- if(test.r > max.r)
- max = test;
- test = texelFetch(ReductionTexture, frag + ivec2(1, 0), 0);
- if(test.r > max.r)
- max = test;
- test = texelFetch(ReductionTexture, frag + ivec2(1, 1), 0);
- if(test.r > max.r)
- max = test;
- FsColor = max;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement