Midpoint displace alg improvement
- From: John Mackay <me@xxxxxxxxxxx>
- Date: Sat, 01 Apr 2006 14:24:49 GMT
Hi,
I'm interested in writing a 3d program which can generate random terrain real-time (i.e. ROAM style). I'm hoping to use the midpoint displacement algorithm, with a few tweaks. I just wanted to get an opinion on the first improvement I thought of, which is basically to modify the multiplier for the next displacement using the current height of the midpoint - i.e. the higher the midpoint, the more displaced it is. The idea being that lower ground would be smoother, higher ground more rocky.
I'm not really sure how to describe this properly, so I've pasted the source code below (just 2d for now). Does this qualify as a multifractal? I can't see anywhere that this has been described on the internet - has anyone done this before? It only really works sensibly if the y values are between 0 and 1.
Cheers,
John
void Calc_Fractal (float x1,float y1,float x2,float y2,int I,float H)
{
float x3 = (x1 + (x2 - x1) / 2);
float r = H * Jrand (x3);
float y3 = (y1 + (y2 - y1) / 2) + r;
float Hm = y3;
if (Hm>0.8) Hm=0.8; // clamp values
if (Hm<0.2) Hm=0.2;
if (I < Iterations)
{
Calc_Fractal (x1, y1, x3, y3, I+1, H*Hm);
Calc_Fractal (x3, y3, x2, y2, I+1, H*Hm);
}
else // draw line
{
acquire_screen ();
line (screen, (int)(x1*300), 480 - (int)(y1*300), (int)(x2*300), 480 - (int)(y2*300), makecol(255, 255, 255));
release_screen ();
}
}
.
- Follow-Ups:
- Re: Midpoint displace alg improvement
- From: caos . snow
- Re: Midpoint displace alg improvement
- Prev by Date: Re: Fwd: Euclid
- Next by Date: Re: m_Fieg_Bezier_Ridlle.avi (video/x-msvideo Object)
- Previous by thread: Fwd: Euclid
- Next by thread: Re: Midpoint displace alg improvement
- Index(es):
Relevant Pages
|
|