From 06fa6eaeb64089b055c0888652e66573c2734db6 Mon Sep 17 00:00:00 2001 From: Samuel Iglesias Gonsalvez Date: Wed, 4 Mar 2015 10:19:26 +0100 Subject: [PATCH] jellyfish: sin(x) with x = y mod 2*pi --- data/shaders/jellyfish.vert | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/data/shaders/jellyfish.vert b/data/shaders/jellyfish.vert index c125370..828e692 100644 --- a/data/shaders/jellyfish.vert +++ b/data/shaders/jellyfish.vert @@ -19,6 +19,8 @@ varying vec4 vWorld; varying vec3 vDiffuse; varying vec3 vAmbient; varying vec3 vFresnel; + +#define M_PI 3.14159265358979323846 void main(void) { @@ -27,9 +29,9 @@ void main(void) float offset = smoothstep(0.0, 1.0, max(0.0, -aVertexPosition.y-0.8) / 10.0); vec3 pos = aVertexPosition + aVertexColor / 12.0 * - sin(speed * 15.0 + aVertexPosition.y / 2.0) * (1.0 - offset); + sin(mod((speed * 15.0 + aVertexPosition.y / 2.0), (2.0 * M_PI))) * (1.0 - offset); pos = pos + aVertexColor / 8.0 * - sin(speed * 30.0 + aVertexPosition.y / 0.5) * (1.0 - offset); + sin(mod((speed * 30.0 + aVertexPosition.y / 0.5), (2.0 * M_PI))) * (1.0 - offset); vec4 pos4 = vec4(pos, 1.0); gl_Position = uWorldViewProj * pos4; -- 2.1.4