Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 330
- //fragment shader output
- layout(location=0) out vec4 vFragColor;
- //input from the vertex shader
- smooth in vec2 vUV; //current texture coordinates
- //shader uniforms
- uniform sampler2D x0; //old density or velocity field
- //determine texture size
- float sizeX = textureSize(x0, 0).x;
- float sizeY = textureSize(x0, 0).y;
- float stepX = 1.0/sizeX;
- float stepY = 1.0/sizeY;
- void main(void)
- {
- vec4 C = texture(x0, vUV);
- vec4 N = texture(x0, vUV + vec2( 0 , -stepY));
- vec4 S = texture(x0, vUV + vec2( 0 , stepY));
- vec4 W = texture(x0, vUV + vec2(-stepX, 0 ));
- vec4 E = texture(x0, vUV + vec2( stepX, 0 ));
- vFragColor = -4*C + N + S + W + E;
- }
Advertisement
Add Comment
Please, Sign In to add comment