user4959397
user4959397

Reputation:

How to use SimplexNoise for 1D

I've been playing around with Simplex Noise. But I still dont know how I should use it right. My Goal is to get a terrain for an Sidescroller game. It shoud have a polygonal style look.

I got the source for SimplexNoise from here

Questions:

Upvotes: 0

Views: 341

Answers (1)

Michal
Michal

Reputation: 3632

If you need only one dimension noise simply ignore second argument. Like this:

getNoise(variable, 0);

The getNoise method in SimplexNoise takes two integer parameters x and y, which are the 2D coordinates of the point for which you want to generate noise. The values of x and y determine the position of the point in the noise space. The output of the getNoise method is a floating-point value between -1 and 1, which represents the noise value at that point.

When people use a nested for loop with i and j values to call getNoise(i + x, j + z), they are generating a 2D array of noise values, where i and j are the indices of the array. By adding x and z to the indices, they are shifting the noise space so that it aligns with the position of the terrain in the game.

The values of largestFeature and persistence in SimplexNoise are used to control the characteristics of the generated noise. largestFeature determines the scale of the features in the noise, while persistence determines the roughness or smoothness of the noise. You can adjust these values to create different types of noise patterns, but keep in mind that changing them will affect the entire noise map.

If you want to generate different types of terrain with different noise patterns, you can create multiple instances of SimplexNoise with different parameters. For example, you could create one instance with a larger largestFeature value to generate big mountains, and another instance with a smaller largestFeature value to generate small hills. By combining the noise maps generated by these instances, you can create a more varied terrain.

Upvotes: -1

Related Questions