Hey guys, I’ve been working on a voxel terrain of late and its been going well.
But now i must ask of you, how is the best way to generate a heightmap from a series of values?
Would perlin noise be the best way to achieve this?
Creating the values ----> Applying them to a texture --------> Grayscaling it -----------> My reading code
^That is my train of thought right now
What I have right now is the ability to read the pixels in a heightmap and build a voxel terrain from it, all I need to do now is to make the heightmap randomly.
I think you dont need to apply it on a texture or grayscale them,
just create “grayscaled” values on the fly for the terrain (or put the values into array first and read from there)
Actually this diamond square thing might be useful also (just would have to fix those visible sharp “corners” / grids or make a new better version of it) Diamond Square Algorithm « Unity Coding – Unity3D (see image#4)
Quick test for basic perlin (js), put this script to plane object:
#pragma strict
private var size:int=128;
private var noiseScale:float = 0.02;
function Start ()
{
// create texture image
var texture = new Texture2D (size, size);
renderer.material.mainTexture = texture;
// draw heighmap
for (var y:int=0;y<size;y++)
{
for (var x:int=0;x<size;x++)
{
var value:float = Mathf.PerlinNoise(x*noiseScale,y*noiseScale);
texture.SetPixel(x,y,new Color(value,value,value,1));
}
}
texture.Apply();
}