Simple Planet Texture Generation 03


In this article series we are going to discuss the creation of a simple planet texture generator that will allow us to texture a three dimensional sphere.

In the first short article we started by looking at building a sphere out of a textured box. In the second one we created a height map generator using simplex noise. In this, the last article, we will be taking the height map and colouring it according to some simple rules to give the visual effect of a planet seen from space. I'm going to use C# and keep it as straight forward as possible so that it can be easily ported to other languages.

The Colours
Ok so now we have a height map from article two that is lying in a buffer, we can use this buffer to texture the sphere from the first article but we want to give it some colour so it would look something like this:
Continued below....

So how are we going to do this? As simply as possible. We are going to take the height map and for each pixel, which is a byte in the range of 0-255, select a colour according to its range and put that colour in a destination buffer that we are going to use as our final texture for the sphere.
Here is the structure for each of the 'regions':


We then populate the array of regions like so:


Now we have a set of regions that will define a colour for each height map value from pixel value 0 to 255 and will populate the destination buffer/texture like so:


Now all that is left to do is wrap the texture around our sphere mesh and you have a little planet:


So that's it, if you have some knowledge in the field of programming you will be able to figure out all the other nitty-gritty things of implementing this planet generator, this was not a step-by-step tutorial so please feel free to ask questions and use Google. :D

PS. Please note this is my first set of articles so please leave suggestions in the comments, also if you find parts of this article that you could improve upon please share with us, this would make it worthwhile for me to have written this as well as contribute to everyone's learning. :)

0 comments: