我正在尝试想出一种技术来生成流星陨石坑的高度图。目前我试图保持小而简单,并有一个简单的算法,其中标记了陨石坑的中心,并在其半径内,其周围的像素根据它们与中心的距离而着色。
这种方法的问题是它会产生 V 形坑,我需要更多的“U”形结果。我对正弦波的使用不熟悉,而且我觉得考虑到流星半径内可能有多少像素,插值不会很快工作。
有什么建议吗?
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?
发布评论
评论(1)
我假设您有一个纹理或其他图片格式,可以在宽度和高度 (x,y) 上进行索引,并且陨石坑也以 x,y 形式给出,其中 x,y 在纹理内,这将产生这样的算法。
这里最重要的一行可能是
看看余弦曲线http://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Cos.svg/500px-Cos.svg.png 它有一个非常光滑的“火山口状”从 Pi 舍入到 TwoPi。由于我们的距离变量从 0~1 缩放,因此我们使用距离 *Pi + Pi。但这会给我们一个从 -1 到 1 的结果。因此,我们将最终结果加 1,然后除以 2,以获得 0 到 1 之间高度的平滑结果。
我希望这对您有所帮助。
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.