Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uniform sampler2D u_texture; // Input texture
- uniform float u_time; // Time since the start of the program
- uniform vec2 u_texelSize; // Texel size of the input texture
- varying vec2 v_texCoord0;
- const float blurSize = 5.0; // Size of the blur kernel
- void main() {
- vec2 uv = v_texCoord0;
- // First pass: horizontal blur
- vec4 sum = vec4(0.0);
- for (float i = -blurSize; i <= blurSize; i++) {
- float offset = i * u_texelSize.x;
- vec4 color = texture2D(u_texture, uv + vec2(offset, 0.0));
- sum += color;
- }
- vec4 horizontalBlur = sum / (2.0 * blurSize + 1.0);
- // Second pass: vertical blur
- sum = vec4(0.0);
- for (float i = -blurSize; i <= blurSize; i++) {
- float offset = i * u_texelSize.y;
- vec4 color = texture2D(u_texture, uv + vec2(0.0, offset));
- sum += color;
- }
- vec4 verticalBlur = sum / (2.0 * blurSize + 1.0);
- vec4 color = texture2D(u_texture, uv); // Get input color
- vec4 tintColor = vec4(1, 1, 1, 0.9);
- vec4 tintedColor = color * tintColor;
- vec2 center = vec2(0.5, 0.5);
- float distance = length(uv - center);
- float amplitude = 0.01;
- float frequency = 3.0;
- float phase = u_time * frequency;
- vec2 offset = vec2(cos(phase), sin(phase)) * amplitude * (1.0 - distance);
- vec4 finalColor = texture2D(u_texture, uv + offset) * tintColor; // Get color at the offset texture coordinate
- gl_FragColor = mix(finalColor, verticalBlur, 0.5); // Output the final color, using a 50/50 mix of the offset color and the vertical blur
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement