Member-only story
I made my own noise function

📝 What is a “noise function”?
In Computer Graphics, a “noise function” refers to a mathematical function that produces a seemingly random, but deterministic, output.
We often use those functions to procedurally generate textures, terrains, and other visual elements.
The most commonly used noise functions might be Perlin noise and Simplex noise.
Why would you make your own noise function?
Usually, noise functions take a cartesian 1D, 2D or 3D point as input, and returns a value between 0 and 1. This means that the input space is a grid, usually the world space (2D or 3D) of your game, or a 1D “grid” along an axis.
In my game, Warmonger Dynasty, the grid is hexagonal, and I use a cubic coordinate system. It is a 2D coordinate system, where each point have 3 components: Q, R and S such that:
For more information about this coordinate system, I invite you to read this article:
To understand why that makes a huge difference, let’s see how noise functions are usually implemented.
📉A simple 1D noise function
The first step is to generate random values at a regular interval. Here, we will generate 5 values at each integer input:

public class Noise1D {
private float[] randomValues;
Noise1D(int maxVertices) {
var rndGen = new System.Random();
randomValues = new float[maxVertices];
for (int i = 0; i < maxVertices; i++) {
randomValues[i] = (float)rndGen.NextDouble();
}
}
// ...
}
Our noise function should return those values for the integer inputs:
public class Noise1D {
// ...
public float Get(float x) {
var ix = (int) x;
var qx = x - ix…