Did anyone ever come across a really good implementation of Perlin noise done in a fragment shader anywhere?
Did anyone ever come across a really good implementation of Perlin noise done in a fragment shader anywhere?
Not Perlin noise but "simplex noise".
Do a seach for it in the OpenGL Shading Forum.
That old GLSL demo of mine actually had regular Perlin noise as well as simplex noise in there, it was just not the default. Look at the shader source and you will see six functions: both regular and simplex noise for 2D, 3D and 4D noise. It's a pretty hefty shader, but it does run on any Nvidia card from FX5xxx and up, and with good performance on anything from FX6800 and up. On some older ATI cards the 3D and 4D versions exceed the maximum instruction count, but the 2D versions work fine even on pretty outdated hardware.
Here's the "improved" Perlin noise.
http://free-zg.htnet.hr/KishBros/Kre...W/PerlinHW.htm
I doubt you'll find it very useful, it pretty much eats up the entire instruction count on SM2 hardware.
In the NVSDK you can look at:
MEDIA/programs/cg_gnoise/fp16noise.cg
For an implementation of Perlin's traditional
noise function.
It's part of the cg_gnoise demo.
I've been thinking about doing one for simplex noise as well.
Cass Everitt -- cass@xyzw.us
Have a look at simplex noise paper and implementation with source code:
simplex noise
and at the bottom of this page:
noise example
kon
Hiya,Originally Posted by kon
thanks very much for sharing your code. I'm looking forward to giving it a go!
Do you happen to have example textures for use with the example shaders, to get me started?
Cheers,
a|x
http://machinesdontcare.wordpress.com
I'm not sure if this helps, but I commonly use a lookup table for noise. I generate noise at startup and quantize into a reasonably sized 3D texture. I use 8x8x32 with a 32-bit RGBA (each component is 8 bits) color texture. On some of the more recent cards, a texture less than 8K will fit entirely in the texture cache (or so it seems from some of my perf tests). I address the texture using vec3 texcoord = gl_FragCoord.xyz * vec2(0.125, 0.125, sample / 32) with the addressing mode set to repeat and the filtering mode set to nearest. Hope this helps.
Kevin B
There are builtin noise functions in GLSL.
There currently is a discussion on the Mesa mailing list about how to implement noise the best way. The proposal currently discussed seems to work fine even on Intel cards.
Philipp
Maybe I've got the wrong end of the stick here.. is the 4-channel noise texture kon mentions in the readme in the example zip (I downloaded the MacOS X port package) simply an RGBA texture with random values in all channels? Or, are the values in the alpha channel different to those in the other 3 channels?
Sorry again for asking stupid questions,
a|x
http://machinesdontcare.wordpress.com