Advertisement
Guest User

Untitled

a guest
Jan 19th, 2014
1,161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. uniform sampler2D ReductionTexture;
  2. uniform vec2 TexelSize;
  3. uniform int Iteration;
  4. uniform int Mode; // 0 == initalize, 1 == reduce
  5.  
  6. smooth VSData vec2 TexPos;
  7.  
  8. uniform mat4 Orthographic;
  9.  
  10. #ifdef VERTEX_SHADER
  11. in vec2 Vertex;
  12.  
  13. void main()
  14. {
  15. vec4 result = Orthographic * vec4(Vertex, 0, 1);
  16. gl_Position = result;
  17. TexPos = Vertex;
  18. }
  19.  
  20.  
  21. #elif defined FRAGMENT_SHADER
  22. out vec4 FsColor;
  23.  
  24. void main()
  25. {
  26. ivec2 frag = ivec2(TexPos);
  27. if(Mode == 0)
  28. {
  29. FsColor = texelFetch(ReductionTexture, frag, 0);
  30. return;
  31. }
  32.  
  33. frag *= 2;
  34. vec4 max = texelFetch(ReductionTexture, frag, 0);
  35. vec4 test = texelFetch(ReductionTexture, frag + ivec2(0, 1), 0);
  36. if(test.r > max.r)
  37. max = test;
  38. test = texelFetch(ReductionTexture, frag + ivec2(1, 0), 0);
  39. if(test.r > max.r)
  40. max = test;
  41. test = texelFetch(ReductionTexture, frag + ivec2(1, 1), 0);
  42. if(test.r > max.r)
  43. max = test;
  44.  
  45. FsColor = max;
  46.  
  47. }
  48.  
  49. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement