Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, ChrstphFr), 875 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Realistic water paths on randomly generated terrains #417513
02/13/13 13:30
02/13/13 13:30
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Are any of you familiar with DiamondSquare algorythims? I started to use these last summer to create beautifull randomly generated terrains (in my opinion these give the most natural looking shapes to random terrains).
www.youtube.com/watch?v=9HJKrctqIJI

I implemented this for terrains in 3DGS and with help from EvilSOB and JibbSmart I learned to write shaders in order to texture my massive randomly generated terrains at runtime.
www.youtube.com/watch?v=gjGJeNkAO3M

Currently I am back to this idea, but my game has changed from terrains to tile-based (thanks to Superku, sivan, and Uhrwerk for dynamic array allocation) because I find this approach easier for pathfinding, line-of-sight, creating random buildings/dungeons, etc... So my new "terrains" are made out of cubes/tiles and look like this:

*No texturing has been implemented yet (still working on a new shader) so they seem very flat, but believe me they are not. They are just massive (2048,2048 tiles). Each cube is "only" 32 (each edge) in size, but the map's heights range from zero to 2048. So believe me there is a lot of variation in the terrain even though it is not aparrent from so far away.

Now I am tackling a new problem... Creating realistic river paths. I do not want any code, what I am stuck with is the logic.
With the heightmap that this algorythim produces it is easy to create seas, oceans, and sea-level lakes. All I do is choose a height I want the sea level to be, label all the tiles at that level or below as "water texture" tiles, and raise them all to the chosen sea-level height.
The problem now is to create rivers and their origins (above sea-level lakes). I cannot place these lakes and rivers randomly on the heightmap because they look completely wrong if they dont look like they could flow in those directions according to the terrain inclination.

So I know I have to use the height data to create them, but I am stuck on the logic I would need to implement...
How would I decide where to place the origin of a lake?
How would I decide to what height the lake covers (what tiles to label as "water texture")?
How should I decide how the river should extend?
How would I decide where the limits are that differentiate the lakes from their rivers so I know which tiles (lake tiles) I have to raise and to what height?
All this using my height data and withough flooding the whole level...

Any ideas on how to approach this problem are welcome


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: Realistic water paths on randomly generated terrains [Re: Carlos3DGS] #417523
02/13/13 15:11
02/13/13 15:11
Joined: Apr 2005
Posts: 4,506
Germany
F
fogman Offline
Expert
fogman  Offline
Expert
F

Joined: Apr 2005
Posts: 4,506
Germany
Odd idea to get at least a realitic river track:
Place a PhysX sphere at the source of your river and let it roll down into the valley.
Track its position into an array and you got a path. Now lower the terrain along this path.


no science involved
Re: Realistic water paths on randomly generated terrains [Re: fogman] #417534
02/13/13 16:06
02/13/13 16:06
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Not really a viable option for me.
Where would I place the ball? If it was at where the lake should be, I have not yet created the lake or determined its size and filled it up, so it would fall down into where the lake would be (an empty valley). Also, remember these are cubes/tiles, not actually terrain, so they are flat on the top, the ball would not actually move.
But even if all those issues got resolved, this is a 2048x2048 size map. Those are waaaaay too many entities to load (I only load large portions of the map for test purposes to see what it looks like, but at 3 fps), it would take way too long to do this at runtime for the player. Even if it were a small map that had 512 fps this aproach is too slow, but considering doing this at 3 or less fps is impossible.

I would prefer a solution programmed myself, not using somebody else's (physX) algorythim. And I am looking for game logic that I can program myself to do the calculation mathematically on my height data withought loading the level. which would be much faster, virtually instantaneous (in only 1 frame, even though it might be a relatively slow frame).

I actually never load the level, I use a FOV+LOS algorythm to only load a relatively small amount of tiles visible around the player. And I dont want to load all of them for my river/lake calculations either. The amount of tiles (4.2 million only counting the ground tiles) is crazy!

EDIT:
fov= field of view
los= line of sight

Last edited by Carlos3DGS; 02/13/13 16:58.

"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: Realistic water paths on randomly generated terrains [Re: Carlos3DGS] #417539
02/13/13 17:24
02/13/13 17:24
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Even though I didnt like the physX approach, thinking about the ball you said pushed my mind in the direction to the solution to my rivers!
And analyzing how that would be a problem because it would fall into the vallys for the lakes gave me a great idea for the lakes and borders between lakes and rivers!
So even though I am not going to use PhysX, thanks alot for pushing me in the right direction!

Even when discarding ideas, having someone else take a look at problems from the outside always brings a fresh point of view when I am stuck! Never discard a concept you dont like before considering ramifications of that idea!


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: Realistic water paths on randomly generated terrains [Re: Carlos3DGS] #417948
02/19/13 20:27
02/19/13 20:27
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com

Moderated by  checkbutton, mk_1 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1