View Full Version : Gradient from Simplex Noise?
09-20-2010, 04:03 AM
I'm using Stefan Gustavson's GLSL simplex noise code (http://webstaff.itn.liu.se/~stegu/simplexnoise/)
But one thing I'm unsure about is that while the implementation returns a noise value for a sample point, I can't see how to get the gradient at the sample point. I'm keen on getting the gradient for bump mapping and according to Wikipedia, cheap extraction of gradient is supposed to be one of the selling points of simplex noise.
Can anyone help?
09-20-2010, 07:55 AM
I don't know if the following may help you. To compute the gradient of the noise function you can use the algorithm used in this file (http://mrl.nyu.edu/~perlin/homepage2006/bumpy/Sphere.java) on this web page (http://mrl.nyu.edu/~perlin/homepage2006/bumpy/index.html). The algorithm in fact compute (estimate) the gradient of the noise function at point (x,y,z) with finite difference.
09-20-2010, 03:20 PM
Yeah, I've seen that stuff from Perlin before. The problem is that he's using multiple samples of precomputed patches of noise rather than generating the noise on the GPU.
I'm hoping to generate noise at runtime and was especially interested in Simplex noise since it's supposed to allow fast calculation of the gradient at any point. It's specifically that latter part - how to get gradient from Simplex noise that I'm interested in.
09-20-2010, 06:52 PM
Maybe you have previously read this (http://www.csee.umbc.edu/~olano/s2002c36/ch02.pdf). Look at the New pseudo-random generator primitive section at page 17. It is written:
The new method converts a six bit pseudo-random index into a visually uniform gradient vector which is
easy to integrate into a derivative calculation and which requires no multiplies to compute. The key
innovation is to use values of only zero or one for the gradient magnitude...
I must admit that I don't understand well the algorithm for now, but it is possible to compute the derivative of the simplex noise with small number of bit operations and two additions.
09-20-2010, 08:58 PM
Thanks very much for that - given that it's commentary on the simplex algorithm from Perlin it might shed some light on the subject, but I must admit that I'm still not sure I understand the code well enough to figure out how to extract the derivative, but I will keep at it.
03-14-2011, 06:37 AM
I am very sorry for being this late to comment on this, but hopefully someone will find this response useful when searching through the forum archives.
Simplex noise has a simple analytic derivative which you can compute with little extra effort. I have not implemented this in GLSL, at least not yet, but a C version which shares the general algorithmic structure of my GLSL version is here:
The file you want is "sdnoise1234.c" in the zip archive.
Porting that to GLSL should be a reasonably straightforward matter. Sadly, I haven't found the time to do that myself.
Please note that using the automatic derivatives Dx() and
Dy() in GLSL works quite well for computing approximate
derivatives, and they come at a very small additional cost.
Therefore, the need for an analytic derivative of noise is not quite as large as one would imagine.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.