Outerra forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Outerra Tech Demo download. Help with graphics driver issues

Author Topic: question regarding fractual terrain and multiplayer  (Read 8198 times)

th3flyboy

  • Newbie
  • Posts: 9
  • newbie
question regarding fractual terrain and multiplayer
« on: January 13, 2012, 05:26:47 pm »

Hello, I've been reading up on virtual globes, and I have been wondering something. How does Outerra handle fractal terrain in a networked multiplayer environment? Specifically, how is it ensured that the terrain is the same for all the clients in a multiplayer situation?

I've been wrapping my head around how to handle fractual terrain in a multiplayer environment for a while now, but I just can't figure out how to make sure that all clients see the same terrain, and making sure there are not differences in terrain between multiple clients.

Thanks,
Flyboy
Logged

Lieste

  • Jr. Member
  • *
  • Posts: 14
  • newbie
Re: question regarding fractual terrain and multiplayer
« Reply #1 on: January 14, 2012, 12:50:32 am »

Why? Fractals are merely a method of storing high complexity in a small storage requirement - the same seed will result in the same output. I suspect you are confusing "random" terrain generation from a pseudo-random seed with procedural enhancement of a rigidly defined base terrain.

There will be some variations in local terrain form when viewer and target are widely separated, but these are consistent with LOD problems with any definition of terrain complexity and efficient reproduction, and the fractal nature of the data refinement is not fundamentally different.

The ultimate point is that bulk terrain features are represented in the DEM data, and only detail refinements are held in the various subscale details added by fractals.
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com
Re: question regarding fractual terrain and multiplayer
« Reply #2 on: January 14, 2012, 08:47:28 am »

Lieste is right, though I guess the question was more about how the pseudo-random numbers are generated so that the terrain is the same. Clearly one cannot use a single pseudo-random generator to get the random numbers for the fractal, because the random numbers picked would be different every time, depending on the sequence of tiles being generated and the initial state of the PRNG.

The random number generation must be deterministic, and so to compute a pseudo-random value for given coordinates of terrain, the equation must involve just the local parameters. For example, you could use the world coordinates as the input, and compute the value from that.
In fact it's not a PRNG anymore, since it cannot have a state, but it's a pseudo-random permutation (PRP). The purpose of PRP is to generate a random-looking output from an input that is usually coherent, like the coordinates are.

If the input isn't very regular, or if the random value is accumulated as in the fractal noise algorithm, you can use a simple LCG equation like this:
Code: [Select]
out = 3141592653UL*in + 1
If the input is regular and the generated numbers are used directly, for example to displace tree positions, this would produce ugly patterns. In that case you need to use something  better. Here's code that returns 4-vector of pseudo-random numbers, PRP-ing 2D integer input coordinates:
Code: [Select]
float4 random_2d_perm( int2 coord )
{
    const int4 D = int4(1, 17, -43, 71);
    const int4 K = int4(2047483673, 1951307951, 1815206923, 1664526161);

    int4 p = (K*coord.x + D)*coord.x;
    p += coord.y;
    p = (K*p + D)*p;

    return float4((p&0xffff) - 0x8000) * float(1.0/0x8000);
}
Logged

th3flyboy

  • Newbie
  • Posts: 9
  • newbie
Re: question regarding fractual terrain and multiplayer
« Reply #3 on: January 14, 2012, 09:34:51 am »

Thanks, that explains where I was stumbling, I was still thinking of using a pseudo random number generator, and not basing it on pseudo random permutations.
Logged