Permalink
Browse files

Added 4D classic noise, declutter, speedups, removed dep of noiseStdL…

…ib.glsl, benchmark changed to test all six versions of noise.
  • Loading branch information...
1 parent 7e87323 commit c2e657b4386e9c4e9d0e58060c507da3241ffa12 @stegu stegu committed Apr 3, 2011
View
@@ -1,4 +1,5 @@
-Copyright (C) 2011 by Ashima Arts
+Copyright (C) 2011 by Ashima Arts (Simplex noise)
+Copyright (C) 2011 by Stefan Gustavson (Classic noise)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -17,4 +18,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-
View
16 README
@@ -1,14 +1,12 @@
-
This work follows Stefan Gustavson's paper "Simplex noise demystified"
-http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
+http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
without using uniform arrays or texture engines.
-A single vec4 uniform 'pParam' is used to set the length and a and
-c constants respectively of the permutation polynomial to use. The
-last element of the vec4 is the number of gradients to select from
-on the vertices. An example vec4 is ( 19*19, 2*19, 1, 7 )
-
-Refer to http://en.wikipedia.org/wiki/Permutation_polynomial for
-more information on permutation polynomials.
+The resulting noise functions are fast and self contained,
+and their performance scales well with massive parallelism.
+Simplex noise functions are (C) Ashima Arts
+Classic noise functions are (C) Stefan Gustavson
+Source code for the noise functions is released under the
+conditions of the MIT license. See the file LICENSE for details.
View
@@ -1,5 +1,6 @@
-SHADERS=GLSL-ashimanoise.vert GLSL-ashimanoise2D.frag \
- GLSL-ashimanoise3D.frag GLSL-ashimanoise4D.frag
+SHADERS=noisebench.vert simplexnoise2D.frag simplexnoise3D.frag\
+ simplexnoise4D.frag classicnoise2D.frag classicnoise3D.frag\
+ classicnoise4D.frag constant.frag
COMDIR=../common
VPATH=$(COMDIR)
EXECNAME=noisebench
@@ -19,4 +20,3 @@ clean:
run:
./$(EXECNAME)
cat $(OUTPUTFILE)
-
@@ -3,8 +3,9 @@ OUTPUTFILE=ashimanoise.log
COMDIR=../common
OBJS=noisebench.o
-SHADERS=GLSL-ashimanoise.vert GLSL-ashimanoise2D.frag \
- GLSL-ashimanoise3D.frag GLSL-ashimanoise4D.frag
+SHADERS=noisebench.vert simplexnoise2D.frag simplexnoise3D.frag\
+ simplexnoise4D.frag classicnoise2D.frag classicnoise3D.frag\
+ classicnoise4D.frag constant.frag
VPATH=$(COMDIR)
CFLAGS=-I. -I/usr/X11/include
@@ -27,6 +28,5 @@ clean:
- rm $(EXECNAME) links_done $(OBJS) $(SHADERS) $(OUTPUTFILE)
run:
- open -W -a $(EXECNAME)
+ open -W ./$(EXECNAME).app
cat $(OUTPUTFILE)
-
View
@@ -3,7 +3,8 @@ MINGW32 = C:/Dev-Cpp
#MINGW32 = C:/mingw
CC = gcc.exe
SRC = noisebench.c
-SHADERS = GLSL-ashimanoise.vert GLSL-ashimanoise2D.frag GLSL-ashimanoise3D.frag GLSL-ashimanoise4D.frag
+SHADERS = noisebench.vert constant.frag simplexnoise2D.frag simplexnoise3D.frag\
+ simplexnoise4D.frag classicnoise2D.frag classicnoise3D.frag classicnoise4D.frag
OBJ = noisebench.o
LINKOBJ = noisebench.o
LIBS = -L$(MINGW32)/lib -mwindows -lglfw -lopengl32 -lglu32 -mconsole -g3
@@ -17,17 +18,29 @@ all: $(EXECNAME)
clean:
del $(OBJ) $(EXECNAME) $(SHADERS) $(OUTPUTFILE) $(SRC)
-GLSL-ashimanoise.vert:
- copy ..\common\GLSL-ashimanoise.vert .
+noisebench.vert:
+ copy ..\common\noisebench.vert .
-GLSL-ashimanoise2D.frag:
- copy ..\common\GLSL-ashimanoise2D.frag .
+constant.frag:
+ copy ..\common\constant.frag .
-GLSL-ashimanoise3D.frag:
- copy ..\common\GLSL-ashimanoise3D.frag .
+simplexnoise2D.frag:
+ copy ..\common\simplexnoise2D.frag .
-GLSL-ashimanoise4D.frag:
- copy ..\common\GLSL-ashimanoise4D.frag .
+simplexnoise3D.frag:
+ copy ..\common\simplexnoise3D.frag .
+
+simplexnoise4D.frag:
+ copy ..\common\simplexnoise4D.frag .
+
+classicnoise2D.frag:
+ copy ..\common\classicnoise2D.frag .
+
+classicnoise3D.frag:
+ copy ..\common\classicnoise3D.frag .
+
+classicnoise4D.frag:
+ copy ..\common\classicnoise4D.frag .
$(SRC):
copy ..\common\$(SRC) .
@@ -1,18 +0,0 @@
-#version 120
-
-uniform float time;
-
-/*
- * Both 2D and 3D texture coordinates are defined, for testing purposes.
- */
-varying vec2 v_texCoord2D;
-varying vec3 v_texCoord3D;
-varying vec4 v_texCoord4D;
-
-void main( void )
-{
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- v_texCoord2D = gl_MultiTexCoord0.xy * 16.0 + vec2(0.0, time);
- v_texCoord3D = vec3(gl_MultiTexCoord0.xy * 16.0, time);
- v_texCoord4D = vec4(gl_MultiTexCoord0.xy * 16.0, 0.0, time);
-}
View
@@ -1,25 +1,40 @@
-OPTIONS=-DNORMALISE_GRADIENTS -DCOLLAPSE_SORTNET
+OPTIONS=
SRCDIR=../../src
-COMMON=commonShader.frag $(SRCDIR)/noiseStdLib.glsl
-SHADERS=GLSL-ashimanoise2D.frag GLSL-ashimanoise3D.frag \
- GLSL-ashimanoise4D.frag
+COMMON=commonShader.frag
+SHADERS=simplexnoise2D.frag simplexnoise3D.frag simplexnoise4D.frag \
+ classicnoise2D.frag classicnoise3D.frag classicnoise4D.frag
all: $(SHADERS)
clean:
- rm $(SHADERS)
-GLSL-ashimanoise2D.frag: $(SRCDIR)/noise2D.glsl $(COMMON)
+simplexnoise2D.frag: $(SRCDIR)/noise2D.glsl $(COMMON)
cpp -P -I$(SRCDIR) -DSHADER=\"noise2D.glsl\" \
- -DVTYPE=vec2 -DVNAME=v_texCoord2D\
+ -DVTYPE=vec2 -DVNAME=v_texCoord2D -DNOISEFUN=snoise\
$(OPTIONS) -DVERSION='#version 120' commonShader.frag $@
-GLSL-ashimanoise3D.frag: $(SRCDIR)/noise3D.glsl $(COMMON)
+simplexnoise3D.frag: $(SRCDIR)/noise3D.glsl $(COMMON)
cpp -P -I$(SRCDIR) -DSHADER=\"noise3D.glsl\" \
- -DVTYPE=vec3 -DVNAME=v_texCoord3D\
+ -DVTYPE=vec3 -DVNAME=v_texCoord3D -DNOISEFUN=snoise\
$(OPTIONS) -DVERSION='#version 120' commonShader.frag $@
-GLSL-ashimanoise4D.frag: $(SRCDIR)/noise4D.glsl $(COMMON)
+simplexnoise4D.frag: $(SRCDIR)/noise4D.glsl $(COMMON)
cpp -P -I$(SRCDIR) -DSHADER=\"noise4D.glsl\" \
- -DVTYPE=vec4 -DVNAME=v_texCoord4D\
+ -DVTYPE=vec4 -DVNAME=v_texCoord4D -DNOISEFUN=snoise\
+ $(OPTIONS) -DVERSION='#version 120' commonShader.frag $@
+
+classicnoise2D.frag: $(SRCDIR)/classicnoise2D.glsl $(COMMON)
+ cpp -P -I$(SRCDIR) -DSHADER=\"classicnoise2D.glsl\" \
+ -DVTYPE=vec2 -DVNAME=v_texCoord2D -DNOISEFUN=cnoise\
+ $(OPTIONS) -DVERSION='#version 120' commonShader.frag $@
+
+classicnoise3D.frag: $(SRCDIR)/classicnoise3D.glsl $(COMMON)
+ cpp -P -I$(SRCDIR) -DSHADER=\"classicnoise3D.glsl\" \
+ -DVTYPE=vec3 -DVNAME=v_texCoord3D -DNOISEFUN=cnoise\
+ $(OPTIONS) -DVERSION='#version 120' commonShader.frag $@
+
+classicnoise4D.frag: $(SRCDIR)/classicnoise4D.glsl $(COMMON)
+ cpp -P -I$(SRCDIR) -DSHADER=\"classicnoise4D.glsl\" \
+ -DVTYPE=vec4 -DVNAME=v_texCoord4D -DNOISEFUN=cnoise\
$(OPTIONS) -DVERSION='#version 120' commonShader.frag $@
@@ -1,22 +1,16 @@
VERSION
-// uniform vec4 pParam;
-// Example constant with a 289-element permutation
-const vec4 pParam = vec4( 17.0*17.0, 34.0, 1.0, 7.0);
-
-#include "noiseStdLib.glsl"
#include SHADER
uniform float time; // Used for texture animation
varying VTYPE VNAME ;
+
//
// main()
//
void main( void )
{
- float n = simplexNoise(VNAME);
-
+ float n = NOISEFUN(VNAME);
gl_FragColor = vec4(0.5 + 0.5 * vec3(n, n, n), 1.0);
}
-
Oops, something went wrong.

0 comments on commit c2e657b

Please sign in to comment.