FastNoise - Native Extension for noise generation

It’s time to leave Perlin Noise in the past. Come use FastNoise for Defold, based on FastNoiseLite. Here’s a quick list of why you might want to use it:

More Choices:

You can make 2D and 3D noise of the following types:

  • Perlin
  • OpenSimplex2
  • OpenSimplex2S
  • Cellular (Worley/Voronoi)
  • Value
  • Cubic Value.
  • It also includes fractal noise generation,
  • And domain warping.

If you want to see the kinds of noise you can make, refer to the upstream demo:
https://auburn.github.io/FastNoiseLite/
Or the purely functional(*) Defold HTML5 version: https://defold-fastnoise-4e628e.gitlab.io/
*the “functionality” of it is up for debate. You’ll want the reference handy: Defold Fastnoise / Defold Fastnoise · GitLab

More Faster:

It’s faster than that ole’ perlin.lua that hangs around the forum. My benchmarks say it’s between 2x -3x faster in a direct comparison of points generated/second. And dramatically more if you’re only generating noise (up to ~17million points per second). The plan for the next release is multi-threading, so it will be even faster.

More Easy to Use

There’s a super simple example project to show how to use it as a drop-in replacement for perlin.lua. Three(3) lines of code had to be changed and the dependency added: Defold Fastnoise / Infinite Map · GitLab

local state = fastnoise.new_state({}) -- make a default state
local domain_state = fastnoise.new_state({domain_warp_type =  "opensimplex2"}) -- make a configured state
local noise = fastnoise.get_noise(state, x, y,) -- make 2D noise
noise = fastnoise.get_noise(state, x, y, z) -- make 3D noise

x, y, z = fastnoise.domain_warp(domain_state, x, y, z) -- warp x,y,z according to the domain_warp state.

noise = fastnoise.get_noise(fastnoise.new_state({seed = 80085})) -- one liner

--I'm not advocating you do it this way, just saying that you could
noise = fastnoise.get_noise(fastnoise.new_state({seed = 614412}), fastnoise.domain_warp(fastnoise.new_state({domain_warp_type = "opensimplex2"}), 1, 1, 1))
18 Likes

FastNoise 1.1.0 is here!

You can add https://gitlab.com/defold-fastnoise/defold-fastnoise/-/archive/1.1.0/defold-fastnoise-1.1.0.zip as a library dependency to take advantage of the new features:

  • FastNoiseLite library (i.e. the part that isn’t affected by engine changes) is now compiled and bundled with the zip. This should reduce build time of the engine (not that it was long before, it’s just shorter now), and more importantly use fewer build server resources :slight_smile:
  • Vector3 (and Vector4) support has been added, so now you can ask for Noise using vectors. Vector4 will only do 3D noise and ignores the w input.
  • Vector support includes Domain Warp. It returns a warped Vector3 (so that the original isn’t modified for situations where you might want it to stay the same).
  • Tests have been added to the build process to make an even more robust extension.
  • Gooey was updated in the preview app.

Multi-threading support is on the way, but I didn’t like the first implementation I came up with, so hang tight.

9 Likes