I’m using Stefan Gustavson’s GLSL simplex noise code (Index of /~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?
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 on this web page. The algorithm in fact compute (estimate) the gradient of the noise function at point (x,y,z) with finite difference.
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.
Maybe you have previously read this. 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.
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.
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.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.