SHARE
TWEET

Untitled

a guest Dec 19th, 2014 174 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #version 330
  2. //fragment shader output
  3. layout(location=0) out vec4 vFragColor;
  4.  
  5. //input from the vertex shader
  6. smooth in vec2  vUV;      //current texture coordinates
  7.  
  8. //shader uniforms
  9. uniform sampler2D x0;       //old density or velocity field
  10.  
  11. //determine texture size
  12. float sizeX = textureSize(x0, 0).x;
  13. float sizeY = textureSize(x0, 0).y;
  14. float stepX = 1.0/sizeX;
  15. float stepY = 1.0/sizeY;
  16.  
  17.  
  18. void main(void)
  19. {
  20.     vec4 C  = texture(x0, vUV);
  21.     vec4 N  = texture(x0, vUV + vec2( 0    , -stepY));
  22.     vec4 S  = texture(x0, vUV + vec2( 0    ,  stepY));
  23.     vec4 W  = texture(x0, vUV + vec2(-stepX,  0    ));
  24.     vec4 E  = texture(x0, vUV + vec2( stepX,  0    ));
  25.  
  26.     vFragColor = -4*C + N + S + W + E;
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top