Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Procedural Generation of Terrain

Author
Message
Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 18th Mar 2011 00:49
I am curious, has anyone tried to make a never ending terrain?
FPS Style, you walk and walk and walk and it spontaneously generates a matrix plus trees.
I know how to make a forest, but how could I make it unending?

I looked at UnendingTerrain demo, but it was pretty hard to understand ...
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 18th Mar 2011 01:08
I'm in the process of building a never ending terrain using Blitzwerks Terrain. It would seem to be not all that difficult, but it has it's twists and turns.

When I get closer to something that works consistently I'll post a demo including source.

If it's possible to load more than 1 Advanced Terrain at a time, I suppose it could be done with that too, but it would be slower...

Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 18th Mar 2011 01:23
I was thinking of doing it with matrixes, i need a relative flat surface anyway with some bumps here and there, no elevation at all.
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 18th Mar 2011 03:21
Its impossibe to make a never ending terrain, even with super efficient variable usage, you can never creaet a terrain that you can walk infinitly forwards and be able to have the terrain not change when you return to your original point with the same terrain you started with. Computer memory is not infinite. Although you CAN make terrain that would take an extremely long time to traverse the entire thing. Or make it wrap the player's position around. You could also generate the terrain in real time as the player reaches the ends of what has been generated already.

Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 18th Mar 2011 03:46 Edited at: 18th Mar 2011 03:48
Of course I know it's impossible to make something infinite
My ideea is that after the player walks some time the terrain + triggers + fauna + flora are destroyed and if he returns to the same spot ... well, it will look different.

I am trying something like this to implement with matrix, but I have no clue where to start.

So as the player walks, constant terrain is generated around him and areas that are far off in the distance get destroyed.
Sort of like an ever moving world.
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 18th Mar 2011 18:12
What I've done is create a 4096 x 4096 heightmap that seamlessly wraps. This makes up a "zone". I then separate that into 16 heightmaps of 1024 x 1024 that make up "sectors" in the zone.

With that I can make as many zones as I want. Each with 16 sectors in it. I've set it up so that the map the player is currently on is loaded and the 3 maps along the corner they are closest to. As they move along the map, when they cross the mid point of the map in the X or Z direction the maps on the opposite corner are deleted and the closest maps are loaded. (this is all outside their visual range, but it will be there when they get close enough to see it) This limits the amount of memory taken up by the terrain system so you can maintain a larger set of maps, giving the illusion of a never ending terrain with enough variety that they wont see the same map segment come up again for quite a while.

As they step on to a new map, you move the maps, the player and all the objects to the original map location so you're never straying far from 0,0,0. The server tracks objects and players by their Zone, Sector, and XYZ Position in that sector, so you are moving the world rather than moving the player.

There are other ways of course, but this is how I chose to do it.

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Mar 2011 19:03
It's perfectly possible to make infinite terrain that doesn't change. All you have to do is generate using the coordinates as a random seed. The same seed will give the same series of random numbers and so will generate the same terrain each time you visit that tile.

[b]
Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 18th Mar 2011 19:06
Quote: "It's perfectly possible to make infinite terrain that doesn't change. All you have to do is generate using the coordinates as a random seed. The same seed will give the same series of random numbers and so will generate the same terrain each time you visit that tile."


This is true, but you do not have an infinite amount of memory to store these seeds, so it won't be technically infinite. Still, it's good enough.



Support a charitable indie game project!
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Mar 2011 20:15 Edited at: 18th Mar 2011 20:16
Quote: "This is true, but you do not have an infinite amount of memory to store these seeds, so it won't be technically infinite. Still, it's good enough."


You would be able to visit 10x more terrain sectors than there are atoms in the observable universe using only 34 bytes to store both coordinates. That's infinite enough for me

[b]
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Mar 2011 21:07
When you say "All you have to do is generate using the coordinates as a random seed." what do you mean exactly? Surely you wouldn't want to generate the terrain each time you visit a particular tile?

The idea of using a tile reference as a random seed is a nice one - I'm just unclear about the details of the implementation.
Alkerak
15
Years of Service
User Offline
Joined: 7th Mar 2011
Location:
Posted: 19th Mar 2011 22:48
Quote: "It's perfectly possible to make infinite terrain that doesn't change. All you have to do is generate using the coordinates as a random seed. The same seed will give the same series of random numbers and so will generate the same terrain each time you visit that tile."


I kinda get what your saying, but i'm lost about the implementation.
So you break up the terrain in tiles or we are talking of the "whole" terrain"?
qwe
22
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 20th Mar 2011 02:20 Edited at: 20th Mar 2011 02:21
if terrain tiles are seeds, seemlessly wrapping them together may be an issue

i'd also like to hear more about the implementation from anyone who's thought about it
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 20th Mar 2011 10:18
Quote: "if terrain tiles are seeds, seemlessly wrapping them together may be an issue"


You can save some space along the edges of each tile, and interpolate those parts instead of randomly generating them.

Cheers!
Sven B

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Mar 2011 12:34
Quote: "if terrain tiles are seeds, seemlessly wrapping them together may be an issue"


Yes, I was wondering that too.

Quote: "You can save some space along the edges of each tile, and interpolate those parts instead of randomly generating them."


I suspect the joins would still be very noticeable if you tried that.
qwe
22
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 20th Mar 2011 16:39
i suppose it would depend on the region, and the type of landscape, and the size of the tiles.

somebody has to have implemented something like this in a demo.
qwe
22
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 20th Mar 2011 16:43
i could see having a heightmap within a heightmap... AKA, for a 1024 1024 heightmap, each pixel represents another heightmap that the player can actually walk through.

the value at that pixel is the average height of the walkable (sub)heightmap at that pixel, and each point on the heightmap should also store a seed for randomization (now we need an array for the larger world, not a heightmap).
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Mar 2011 16:46 Edited at: 20th Mar 2011 16:48
Quote: "i suppose it would depend on the region, and the type of landscape, and the size of the tiles."


Yes it would - but it's surprising how well the human eye spots joins like that.

Quote: "somebody has to have implemented something like this in a demo."


Yes, that would be useful to see. Perhaps Diggsey had something specific in mind?

Edit

Quote: "i could see having a heightmap within a heightmap... AKA, for a 1024 1024 heightmap, each pixel represents another heightmap that the player can actually walk through.

the value at that pixel is the average height of the walkable (sub)heightmap at that pixel, and each point on the heightmap should also store a seed for randomization (now we need an array for the larger world, not a heightmap)."


Something along those lines might work.
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 20th Mar 2011 19:33 Edited at: 20th Mar 2011 19:36
Quote: "i could see having a heightmap within a heightmap... AKA, for a 1024 1024 heightmap, each pixel represents another heightmap that the player can actually walk through."


See my post above. I've implemented this, and it works fantastically. I'm just waiting for Kaedroho to figure out how to stitch the seams together better. It's very very close to being perfect though. Even if it uses heightmaps and isn't dynamically generated.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Mar 2011 19:45
I saw that but I don't really follow your method. You start by saying

Quote: "What I've done is create a 4096 x 4096 heightmap that seamlessly wraps. This makes up a "zone"."


You then split that into 16 "sectors".

It's the next bit that confuses me:

Quote: "With that I can make as many zones as I want. Each with 16 sectors in it."


Where do these other zones come from? I think I followed the rest.
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 20th Mar 2011 23:23
I'm reusing the 16 maps to make the terrain, and just calling it by a different sector number. The scale of the 16 terrains together is so large that someone would really have to be paying close attention to the details to notice that it does eventually wrap.

Then I'm using those sector numbers to determine what objects are placed in those sectors. So even though the terrain is the same, the content in each sector is different, giving the illusion of endless terrain, or at least big enough that it will seem endless. I'm starting out with an 8 x 8 sector grid. We'll have to wait and see how endless that seems when there's content in it.

qwe
22
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 21st Mar 2011 01:30 Edited at: 21st Mar 2011 01:31
i'm actually using the seeds/values map that contains many "submaps" idea for my space (and land) exploration game.

you can take readings of the stars and planets and celestial bodies, etc.

http://www.facebook.com/album.php?id=100001075818097&aid=16231

however, i'm reworking the engine atm, and doing school...
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2011 01:37 Edited at: 21st Mar 2011 01:39
What are the zones that you referred to in your first post? How do they relate to the first zone that consists of 16 sectors?

Am I trying to look for a precise distinction that isn't there? I think I was just thrown by your choice of words.

Are you simply saying that the main 4096x4096 terrain is split into 16 sectors as follows:



and a player might wander through these and see, at any one time a sequence of 2x2 adjacent blocks something like this with wrapping:











which joined together would look like:



then I can see it should work well.

It effectively gives you 64 different subzones because each of the 16 sectors can be any one of the four corners. With differing population with buildings, trees, rocks, etc, it really would seem endless as you say.
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 21st Mar 2011 19:50 Edited at: 21st Mar 2011 19:51
That's pretty much it. Each set of 16 maps makes a zone. (I said sector in my last post. Sorry.)

As they wander past the edge of one of the edge maps, they move into the next zone.



So to place a particular object, you store,

- Zone XY location
- Map
- XYZ location

If you use DWORDs for the zone grid, you could effectively have 18,446,744,065,119,617,025 zones.

I think I'll be sticking with an 8x8 zone grid for now though.
Which gives, 8^2 * 16 = 1024 unique map areas.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Mar 2011 21:18
Thanks. I've got it now. Might make use of something like that myself.

Presumably you could add extra variation via lighting and textures as well.

Login to post a reply

Server time is: 2026-07-17 13:59:33
Your offset time is: 2026-07-17 13:59:33