Skip to content

Commit

Permalink
[New Shader] - Distorted Motion Blur (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgtle authored Aug 5, 2024
1 parent 4238036 commit 6e0ac06
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions source/shaders/distorted-motion-blur/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
description: A shader that simulates motion blur and adds a distortion effect when scrolling on the screen.
shader:
title: Distorted Motion Blur
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."
screenshot: distorted-motion-blur.png
video: distorted-motion-blur.mp4
# For the moment we need to record the path to this directory until Static Shock provides this
directory: shaders/distorted-motion-blur/
---
```glsl
# version 460 core
# include <flutter/runtime_effect.glsl>
uniform vec2 u_size;
uniform vec2 u_velocity;
uniform sampler2D u_texture;
out vec4 frag_color;
void main() {
float q = 24.0;
vec2 p = FlutterFragCoord().xy / u_size ;
vec2 v = u_velocity/ u_size / 2;
float o = -pow(p.y * 2 - 1, 6) + 1;
vec4 new_p = vec4(0);
for (int i = 0; i < q; i++) {
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));
}
new_p /= q;
frag_color = new_p;
}
```

0 comments on commit 6e0ac06

Please sign in to comment.