Hi, I’m currently playing with unity and learning c# while I’m at it. I’m having trouble creating some thing like a radial gradient to subtract from perlin noise.
The perlin noise is done. I use the sample value from that to create a sprite. The sprite its self is set depending on the value of sample value, for example so 0 is ocean and 1 is grass.
This is the current script (I’ve removed the irrelevant info):
public int mapWidth;
public int mapHeight;
public float xOrg;
public float yOrg;
public float scale = 10f;
public GameObject tSprite;
void Start()
{
CalcNoise();
}
void CalcNoise()
{
float y = 0.0F;
while (y < mapHeight)
{
float x = 0.0F;
while (x < mapWidth)
{
//Origin +
float xCoord = xOrg + x / mapWidth * scale;
float yCoord = yOrg + y / mapHeight * scale;
float sample = Mathf.PerlinNoise(xCoord, yCoord);
//Debug.Log (sample);
Instantiate(tSprite, new Vector3(x, y), Quaternion.identity);
x++;
}
y++;
}
}
}
What I need to do is create a radial fall off/gradient that I can subtract from the sample float in the perlin noise.
This would/should then result in:
This is what I currently have:
So as you can see I’m about half way through.
I need to figure out a way of creating the gradient in the same loop as the perlin noise so that I can then subtract the gradient from the sample float.
I’ve searched about the place but I’ve been unable to find info that will assist me.
Is any one willing to help?
Thanks!!!