幅と高さ (x,y) でインデックス付けできるテクスチャまたはその他の画像形式があり、クレーターも x,y で指定され、x,y がテクスチャ内にあると仮定すると、このようなアルゴリズムが生成されます。
Texture2D texture = ...;
Vector2 craterPosition = new Vector2(50,50);
double maxDistance = Math.Sqrt(Math.Pow(texture.Width,2) + Math.Pow(texture.Height,2));
for(int x = 0; x < texture.Width; x++)
{
for(int y = 0; y < texture.Height; y++)
{
double distance = Math.Sqrt(Math.Pow(x - craterPosition.x, 2) + Math.Pow(y - craterPosition.y, 2));
//the lower distance is, the more intense the impact of the crater should be
//I don't know your color scheme, but let's assume that R=0.0f is the lowest point and R = 1.0f is the highest
distance /= maxDistance;
double height = (Math.Cos(distance * Math.Pi + Math.Pi) + 1.0) / 2.0;
texture[x,y] = new Color((float)height,0,0,1);
}
}
ここで最も重要な行はおそらく
double height = (Math.Cos(distance * Math.Pi + Math.Pi) + 1.0) / 2.0;
余弦曲線http://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Cos.svg/500px-Cos.svg.pngを見てください。円周率からの滑らかな「クレーターのような」丸みがあります。 TwoPiに。距離変数は 0 ~ 1 の範囲でスケーリングされるため、距離 *Pi + Pi を使用します。しかし、これは -1 から 1 の結果を返します。したがって、最終結果に 1 を加えてから 2 で割り、0 と 1 の間の高さの滑らかな結果を取得します。
これがお役に立てば幸いです。