Skip to content

Commit 6e0ac06

Browse files
authored
[New Shader] - Distorted Motion Blur (#12)
1 parent 4238036 commit 6e0ac06

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed
Binary file not shown.
973 KB
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
description: A shader that simulates motion blur and adds a distortion effect when scrolling on the screen.
3+
shader:
4+
title: Distorted Motion Blur
5+
description: "This shader simulates a motion blur effect with a distortion effect when scrolling. You can find an example implementation of the shader in Flutter here: https://github.com/vgtle/shader_studio/tree/main."
6+
screenshot: distorted-motion-blur.png
7+
video: distorted-motion-blur.mp4
8+
# For the moment we need to record the path to this directory until Static Shock provides this
9+
directory: shaders/distorted-motion-blur/
10+
---
11+
```glsl
12+
# version 460 core
13+
# include <flutter/runtime_effect.glsl>
14+
15+
uniform vec2 u_size;
16+
uniform vec2 u_velocity;
17+
uniform sampler2D u_texture;
18+
19+
out vec4 frag_color;
20+
21+
void main() {
22+
23+
float q = 24.0;
24+
vec2 p = FlutterFragCoord().xy / u_size ;
25+
vec2 v = u_velocity/ u_size / 2;
26+
27+
float o = -pow(p.y * 2 - 1, 6) + 1;
28+
vec4 new_p = vec4(0);
29+
for (int i = 0; i < q; i++) {
30+
new_p += texture(u_texture, vec2(p.x + (( (o - 1) * length(v.y) * 6 * ((p.x - 0.5))) ) + (v.x * i) / q, p.y + 0.01 + (v.y * i) / q));
31+
}
32+
new_p /= q;
33+
frag_color = new_p;
34+
}
35+
36+
```

0 commit comments

Comments
 (0)