From b54c44c6b83ca2490e56ba9b449bdae2d057bd32 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 11 Nov 2018 22:06:30 +1100 Subject: [PATCH] added swirl effect --- effects/effects/swirl.frag | 33 +++++++++++++++++++++++++++++++++ effects/effects/swirl.xml | 14 ++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 effects/effects/swirl.frag create mode 100644 effects/effects/swirl.xml diff --git a/effects/effects/swirl.frag b/effects/effects/swirl.frag new file mode 100644 index 000000000..3c093211e --- /dev/null +++ b/effects/effects/swirl.frag @@ -0,0 +1,33 @@ +#version 110 + +// Swirl effect parameters +uniform float radius; +uniform float angle; +uniform float center_x; +uniform float center_y; +uniform vec2 resolution; + +uniform sampler2D myTexture; +varying vec2 vTexCoord; + +void main(void) { + vec2 center = vec2(center_x, center_y); + + vec2 uv = vTexCoord.st; + + vec2 tc = uv * resolution; + tc -= center; + float dist = length(tc); + if (dist < radius) { + float percent = (radius - dist) / radius; + float theta = percent * percent * (-angle*0.05) * 8.0; + float s = sin(theta); + float c = cos(theta); + tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c))); + } + tc += center; + vec3 color = texture2D(myTexture, tc / resolution).rgb; + gl_FragColor = vec4(color, 1.0); + + +} \ No newline at end of file diff --git a/effects/effects/swirl.xml b/effects/effects/swirl.xml new file mode 100644 index 000000000..962018379 --- /dev/null +++ b/effects/effects/swirl.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file