Snippets created by Krunoslav Saho

  • Perlin/Gradient Noise

    I came looking for a fast implementation of Perlin Noise, but the only code snippet showed value noise, which has discontinuity in its 2nd derivative. This version of Perlin Noise has 3 improvements over the default. 1. 1024 gradient vectors 2. Higher order smoothing polynomial 3. A better hash function This implementation has a slight change for performance reasons, and that is the removal of clamping the smoothing polynomial from 0.0 to 1.0, and no clamp on the final value, which would be from -1.0 to 1.0. I have not experienced any issues as in my code I have offset the values by scaling them into the range of 0.0 -> 1.0. I have tested this and profiled this code for many hours in order get the absolute best performance I could. This code runs much faster in release mode than it does under debug mode. I have profiled in both debug and release modes, and against Heikki Törmälä's SimplexNoise, and in release mode my gradient noise implementation is a lot faster and since it uses doubles the numerical limit is far greater, as the Simplex Noise function fails once the 32bit floats overflow. Keep in mind, this is 2D gradient noise, and I have not tested a 3D version.

    4 people like this

    Posted: 9 years ago by Krunoslav Saho

  • PCG 32bit RNG

    I have tested this against the C code I compiled on the PCG website (http://www.pcg-random.org/download.html). It seems to work fine. Nothing special, I just really loathe System.Random. Why has the de-facto RNG for the .NET library not been updated?

    3 people like this

    Posted: 5 years ago by Krunoslav Saho