Skip to content
This repository
Browse code

Bug fixed (oups), slight speedup to 2D simplex noise

  • Loading branch information...
commit 0f39cd9601928854af3e454e816e69c93f56cbe6 1 parent df3050b
Stefan Gustavson stegu authored

Showing 1 changed file with 4 additions and 4 deletions. Show diff stats Hide diff stats

  1. +4 4 src/noise2D.glsl
8 src/noise2D.glsl
@@ -19,7 +19,7 @@ vec3 taylorInvSqrt(vec3 r)
19 19
20 20 float snoise(vec2 v)
21 21 {
22   - const vec4 C = vec2(0.211324865405187, // (3.0-sqrt(3.0))/6.0
  22 + const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
23 23 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
24 24 -0.577350269189626, // -1.0 + 2.0 * C.x
25 25 0.024390243902439); // 1.0 / 41.0
@@ -49,8 +49,8 @@ float snoise(vec2 v)
49 49 m = m*m ;
50 50
51 51 // ( N points uniformly over a line, mapped onto a diamond.)
52   - vec3 x = 2.0 * fract(p * C.www) - 1.0 ;
53   - vec3 h = abs(x) - 0.5 ;
  52 + vec3 x = 2.0 * fract(p * C.www) - 1.0;
  53 + vec3 h = abs(x) - 0.5;
54 54 vec3 ox = floor(x + 0.5);
55 55 vec3 a0 = x - ox;
56 56
@@ -60,6 +60,6 @@ float snoise(vec2 v)
60 60 // Compute final noise value at P
61 61 vec3 g;
62 62 g.x = a0.x * x0.x + h.x * x0.y;
63   - g.yz = a0.yz * xC.xz + h.yz * xC.yw;
  63 + g.yz = a0.yz * x12.xz + h.yz * x12.yw;
64 64 return 130.0 * dot(m, g);
65 65 }

0 comments on commit 0f39cd9

Please sign in to comment.
Something went wrong with that request. Please try again.