So I’ve been spending a few hours now looking for an algorithm to help me radially generate terrain. All I’ve been able to find is articles of people asking how to generate terrain like in Terraria, however, that’s not what I’m after
Specifically I’m going to use this to random generate asteroids of various sizes, with various minerals and such. From looking at the above mentioned articles, I’ve been able create Terraria like terrain using the following code. Which is a slightly modified version of the popular tutorial found here
GameObject Stone = (GameObject)Resources.Load("Stone");
GameObject Grass = (GameObject)Resources.Load("Grass");
byte[,] blocks = new byte[x, y];
for (int px = 0; px < blocks.GetLength(0); px++)
{
int stone = NoiseGenerator.Noise(px, 0, 20, 20, 1);
stone += NoiseGenerator.Noise(px, 0, 50, 30, 1);
stone += NoiseGenerator.Noise(px, 0, 10, 10, 1);
stone += 25;
int grass = NoiseGenerator.Noise(px, 0, 100, 35, 1);
grass += NoiseGenerator.Noise(px, 0, 50, 30, 1);
grass += 25;
for (int py = 0; py < blocks.GetLength(1); py++)
{
if (NoiseGenerator.Noise(px, py, 12, 16, 1) > 10)
{
Instantiate(Grass, new Vector3(px, py), Quaternion.identity);
}
else if (py < stone && py > -stone /*&& NoiseGenerator.Noise(px, py*2, 16, 14, 1) < 10*/)
{
Instantiate(Stone, new Vector3(px, py), Quaternion.identity);
}
else if (py < grass && py > -grass/*&& NoiseGenerator.Noise(px, py * 2, 16, 14, 1) < 10*/)
{
Instantiate(Grass, new Vector3(px, py), Quaternion.identity);
}
}
}
What I can’t for the life of me wrap my head around, is how would one modify this to create an asteroid-like shape.
Thanks in advance ![]()