I made a program that uses perlin noise to generate a height map. It worked very good. Later I changed it to use simplex noise.
What I want to achieve now is that the left edge fits in the right edge, so I want to make it tileable.
I did some research and found this: https://gamedev.stackexchange.com/a/23639/116727. This formula makes it tileable on every edge but I only want it to be tileable on the left and right edges. Then I found this website: http://www.jgallant.com/procedurally-generating-wrapping-world-maps-in-unity-csharp-part-2/#wrap1. It was just what I needed, with a formula that only tiles on one axis. I the tried to implement it, but I could not get it to work.
Here is my implementation:
//Noise range
double x1 = 0, x2 = 1;
double y1 = 0, y2 = 1;
double dx = x2 - x1;
double dy = y2 - y1;
//Sample noise at smaller intervals
double s = x / xsize;
double t = y / ysize;
// Calculate our 3D coordinates
double nx = x1 + Math.Cos(s * 2 * Math.PI) * dx / (2 * Math.PI);
double ny = y1 + Math.Sin(t * 2 * Math.PI) * dy / (2 * Math.PI);
double nz = t;
float PerlinValue = (float)SimpNoise.Evaluate(nx, ny, nz); //* 2 - 1;
map[x, y] = PerlinValue;
This is the result that I get:
What am I doing wrong? How can I fix this?
x
andxsize
? Could there be integer division happening? \$\endgroup\$