Skip to main content
GameDev.net gamedev.net
🔒 Locked

Infinite terrain

Started by Concentrate Jan 31, 2010 at 7:13 PM 7 replies 1.6k views
Telastyn
Telastyn
Loop around a fixed map.

Defined by some equation/algorithm so the height at any coordinate can be computed on the fly.

The same idea, only the coordinates are used to seed a mapgen which then creates discrete areas on the map (say the terrain for arbitrary planets)
Concentrate
Concentrate
I was thinking to have several heightmaps in a linked list and render
only the one that is in the range of the object view, but am not sure how to
determine the view of the object. Any help?
Elvis Enmanuel
Elvis Enmanuel
Humus to the rescue:
http://www.humus.name/index.php?page=3D&ID=23
Narf the Mouse
Narf the Mouse
Perlin noise terrain: Link


Basically, the height of any point on the terrain depends on the location of said point. So, as long as the centerpoint is always the same...
Concentrate
Concentrate
Quote:
Original post by Narf the Mouse
Perlin noise terrain: Link


Basically, the height of any point on the terrain depends on the location of said point. So, as long as the centerpoint is always the same...


can you explain a bit more please?
Narf the Mouse
Narf the Mouse
Certainly, although it'll be a bit dense. First, pseudo-random number generator theory.

The first thing you have to understand is that computers do not generate actual random numbers. Instead, they take a number (seed) and generate a series of number from that seed. If the proper math is done, the result "looks" random.

For example:

Seeding:Array n[0] = seed * 1376312627;Array n[0] = (((n[0] * (n[0] * n[0] * 15727 + 789181) + 1376312627) & 0x7fffffff));CalculatingArray n = (((n[i - 1] * (n[i - 1] * n[i - 1] * 15727 + 789181) + 1376312627) & 0x7fffffff));


If we put the same seed in, we get the same sequence. This is a pretty basic math principle - The same equation, with the same numbers, yields the same result.
If you check, each of those numbers are prime numbers. I'm not entirely sure why that's needed - But that's what wikipedia and my instincts tell me - Not to mention the page where I got the template. If you want to use it yourself, just change the numbers a bit to other primes. There's webpages that'll find the nearest prime.

However, what happens if we drop in a number based on a location and run it once?

Int32 n = x + y * 1376312627;Int32 n = (((n * (n * n * 15727 + 789181) + 1376312627) & 0x7fffffff));

Let's look at a much simpler equation (mod means modulo, the remained after division - In this case, the remainder after division by 5):

n = (x + y * 2) mod 5
for x = 1 to 5, for y = 1 to 5

34012
01234
23401
40123
12340


In this case, we get a "random" number sequence 5 digits long. But, how about we make it a bit more random. Let's plug x and y into that equation up there...

for x = 1 to 10, for y = 1 to 10

3240010124
1142001330
0112441220
4200201011
0133132420
0301300202
2203013001
3414030433
2004234004
2010334104

Ah, now that's more random.

Now, think of those numbers as heights...It's a very hilly terrain, isn't it? Well, I'm sure the tutorial will help... :)
getafix99
getafix99
I don't know if it's the simplest way, but way not just make a terrain stretched on a big spherical object? kinda like a planet :) it sure is the coolest and most fake way of an inf terrain
rouncED
rouncED
This isnt quite infinite, but you can store gigs of data on the disk and stream it in as you get to it, sorta like virtual textures. then you could have a massive might as well be infinite terrain - but it takes a load to store it.
Intelligent use of mipping will let you see all the way to the end of it from any position, to see really distant mountains.

If you made it spherical like a planet that would be really cool :) but im afraid youll be parting with at least 100 gigs even for a small moon, depending on how much detail you wanted.

If you dont want to store this much, its probably best to go with one of the mathematical generation/fractal methods, which are extremely clever.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.