- Home /
Unexpected period length with Unity Mathematics pnoise method
I'm working on generating tiling 2D terrains with Unity's noise.pnoise
method, but I'm getting odd behavior from the period parameter (most likely there's something about the noise algorithm that I don't understand). When I try to generate periodic (repeating) noise with a period length of 100, I get the expected behavior—the noise repeats after 100m, but when I set the period to 150, the pattern repeats after 300m instead of after 150m. Lastly (and most strangely) when I set the period to 125, the pattern repeats after 500m. The noise output from the 3 period values (100, 150, 125 respectively) can be seen in the image below:
The method to generate the line from the screenshots:
void Graph()
{
lineRenderer.positionCount = positionCount;
Vector3[] positions = new Vector3[lineRenderer.positionCount];
for (int x = 0; x < positions.Length; x++)
{
float2 noiseCoord = new float2(x, 0) * WidthScale;
float2 period2 = new float2(period, 1f) * WidthScale;
float y = -noise.pnoise(noiseCoord, period2) * HeightScale + Offset;
positions[x] = new Vector3(x, y, 0);
}
lineRenderer.SetPositions(positions);
}
Any insights or explanation for why this might be and how I could account for it when trying to generate various lengths of noise would be greatly appreciated! Thanks!
Your answer
Follow this Question
Related Questions
procedurally generated map 0 Answers
Strange texture2d behaviour 0 Answers
Perlin noise generates weird flat spots 1 Answer