- Home /
Procedural planet, apply textures based on height
I'm trying to create a procedural planet inside of unity. I have been "successfully" created the planets mesh using 6 sides of a cube and spherifying each side and then applied height from using noisemaps generated with LibNoise for Unity.
So now that I've generated the mesh I'd like to apply textures to the planet based on the height of the terrain. My plan for doing this is to create a Texture2D based on the data that I applied to the sphere and apply this texture to a shader which handles the texture application.
Is this a good way of handling it? And if so, how do I go about creating the texture? Based on the Demo code provided with LibNoise for Unity you can create textures using a few methods, GeneratePlanar, GenerateCylindrical etc.
//How I get the elevation values
noise.GetValue(vertex.x, vertex.y, vertex.z);
//Generate noisemap
Noise2D noiseMap = new Noise2D(resolution_w, resolution_h, NoiseModule);
noiseMap.GeneratePlanar(left, right, top, bottom)
I'm just a bit confused about what to put as the parameters?
If this is the wrong method, have you got any better suggestions?
Thanks in advance