From 6c2fa45b71901ee380b287c714a2e151a985085e Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 24 Sep 2012 06:44:41 +0000 Subject: [PATCH] core: add some noise to the gradient effect. --- src/gradient.lolfx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gradient.lolfx b/src/gradient.lolfx index 16bbf767..a7404328 100644 --- a/src/gradient.lolfx +++ b/src/gradient.lolfx @@ -37,13 +37,17 @@ mat4 cluster = mat4(12.0, 5.0, 6.0, 13.0, 11.0, 3.0, 2.0, 8.0, 15.0, 10.0, 9.0, 14.0); +float rand(vec2 p) +{ + return fract(sin(dot(p, vec2(12.9898, 78.2333))) * 123.4567); +} + void main() { vec4 col = pass_Color; #if defined GL_ES int dx = int(mod(gl_FragCoord.x, 4.0)); int dy = int(mod(gl_FragCoord.y, 4.0)); - /* Cluster */ float t; if (dx == 0) { @@ -65,6 +69,7 @@ void main() float t = cluster[int(mod(gl_FragCoord.x, 4.0))] [int(mod(gl_FragCoord.y, 4.0))]; #endif + t += rand(gl_FragCoord.xy) - 0.5; t = (t + 0.5) / 17.0; col.x += fract(t - col.x) - t; col.y += fract(t - col.y) - t;