Permalink
Browse files

removed unnecessary floor operations in permute()

  • Loading branch information...
stegu
stegu committed Apr 7, 2011
1 parent b3878ba commit ef0b586f8de234111775dcced86cba50a2716f28
Showing with 15 additions and 11 deletions.
  1. +1 −1 src/classicnoise2D.glsl
  2. +6 −3 src/classicnoise3D.glsl
  3. +3 −2 src/classicnoise4D.glsl
  4. +3 −3 src/noise2D.glsl
  5. +1 −1 src/noise3D.glsl
  6. +1 −1 src/noise4D.glsl
View
@@ -32,7 +32,7 @@
vec4 permute(vec4 x)
{
- return floor(mod(((x*34.0)+1.0)*x, 289.0));
+ return mod(((x*34.0)+1.0)*x, 289.0);
}
vec4 taylorInvSqrt(vec4 r)
View
@@ -32,8 +32,7 @@
vec4 permute(vec4 x)
{
- x = mod(x, 289.0);
- return floor(mod(((x*34.0)+1.0)*x, 289.0));
+ return mod(((x*34.0)+1.0)*x, 289.0);
}
vec4 taylorInvSqrt(vec4 r)
@@ -49,8 +48,10 @@ vec3 fade(vec3 t) {
float cnoise(vec3 P)
{
vec3 Pi0 = floor(P); // Integer part for indexing
- vec3 Pf0 = fract(P); // Fractional part for interpolation
vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1
+ Pi0 = mod(Pi0, 289.0);
+ Pi1 = mod(Pi1, 289.0);
+ vec3 Pf0 = fract(P); // Fractional part for interpolation
vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
vec4 iy = vec4(Pi0.yy, Pi1.yy);
@@ -118,6 +119,8 @@ float pnoise(vec3 P, vec3 rep)
{
vec3 Pi0 = mod(floor(P), rep); // Integer part, modulo period
vec3 Pi1 = mod(Pi0 + vec3(1.0), rep); // Integer part + 1, mod period
+ Pi0 = mod(Pi0, 289.0);
+ Pi1 = mod(Pi1, 289.0);
vec3 Pf0 = fract(P); // Fractional part for interpolation
vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
View
@@ -32,8 +32,7 @@
vec4 permute(vec4 x)
{
- x = mod(x, 289.0);
- return floor(mod(((x*34.0)+1.0)*x, 289.0));
+ return mod(((x*34.0)+1.0)*x, 289.0);
}
vec4 taylorInvSqrt(vec4 r)
@@ -50,6 +49,8 @@ float cnoise(vec4 P)
{
vec4 Pi0 = floor(P); // Integer part for indexing
vec4 Pi1 = Pi0 + 1.0; // Integer part + 1
+ Pi0 = mod(Pi0, 289.0);
+ Pi1 = mod(Pi1, 289.0);
vec4 Pf0 = fract(P); // Fractional part for interpolation
vec4 Pf1 = Pf0 - 1.0; // Fractional part - 1.0
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
View
@@ -2,16 +2,16 @@
// Description : Array and textureless GLSL 2D simplex noise function.
// Author : Ian McEwan, Ashima Arts.
// Maintainer : ijm
-// Lastmod : 20110403 (stegu)
+// Lastmod : 20110407 (stegu)
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
// Distributed under the MIT License. See LICENSE file.
//
vec3 permute(vec3 x)
{
- return floor(mod(((x*34.0)+1.0)*x, 289.0));
+ return mod(((x*34.0)+1.0)*x, 289.0);
}
-
+
vec3 taylorInvSqrt(vec3 r)
{
return 1.79284291400159 - 0.85373472095314 * r;
View
@@ -10,7 +10,7 @@
vec4 permute(vec4 x)
{
- return floor(mod(((x*34.0)+1.0)*x, 289.0));
+ return mod(((x*34.0)+1.0)*x, 289.0);
}
vec4 taylorInvSqrt(vec4 r)
View
@@ -10,7 +10,7 @@
vec4 permute(vec4 x)
{
- return floor(mod(((x*34.0)+1.0)*x, 289.0));
+ return mod(((x*34.0)+1.0)*x, 289.0);
}
float permute(float x)

0 comments on commit ef0b586

Please sign in to comment.