I am trying to come up with a technique to generate a height map for a meteor crater. I’m trying to keep is small and simple at the moment, and have a simple algorithm where the centre of the crater is marked, and within its radius, pixels around it are coloured depending on how close to the center they are.
The problem with this method is it is producing V shaped craters, I require more ‘U’ shaped results. I’m unfarmilliar with the use of sine waves and I get the feeling interpolation wont work very quickly given how many pixels could be inside the meteor radius.
Any suggestions?
I assume you have a texture or other picture format that can be indexed over width and height (x,y) and that the crater is also given in x,y with x,y inside the texture, this would produce an algorithm like this.
The most important line here is probably
Take a look at the cosine curve http://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Cos.svg/500px-Cos.svg.png it has a nice smooth ‘crater like’ rounding from Pi to TwoPi. Since our distance variable is scaled from 0~1 we use distance *Pi + Pi. But this will give us a result from -1 to 1. So we add 1 to the end result and then divide by 2 to get a smooth result for the height between 0 and 1.
I hope this helps you.