• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
csp256

Cellular automata for hydraulic erosion?

3 posts in this topic

I like toying around with World Machine and other procedural terrain generation tools. I'm also trying to learn more about general-purpose GPU programming, so I thought I would see if I could recreate one of my favorite parts of World Machine on the GPU: hydraulic erosion.

 

World Machine's hydraulic erosion function simulates the effect of precipitation on a heightmap, and has four outputs: an eroded heightmap, a water-flow map, a soil-deposition map, and a wear map (that shows where the erosion occurred). It does a pretty good job, and is relatively fast. The starter map you get on start up can be eroded with default settings in ~10 seconds. 

 

I intend to replicate this basic functionality, but with an increase in speed. This is not meant to be boasting or impressive, just a consequence of using the GPU on a parallelizable problem. However I would like to improve upon it with a new feature: meanders and oxbow lakes. http://en.wikipedia.org/wiki/Meander Meanders are when rivers curve significantly, due to increased water flow and erosive force on the exterior of a bend in the river. Excessive curves may cause the river to erode an extra connection to itself, cutting off part of the river from a water source. This results in horse-shoe shaped lakes next to rivers (which may or may not dry up).

 

I would like to see if I can get this to happen as an emergent behavior from a properly constructed cellular automata. In order to see this sort of behavior I would need a model that allowed (1) water flowing next to a cell (which is higher than the water) to cause erosion in that cell, (2) water to flow faster on the outside of a bend, (3) faster moving water to be more erosive, (4) slower water to deposit more soil. I'm not entirely sure how to achieve that. Locally computing the gradient of water altitudes to determine flow rate each time step is the simplest method, but it also fails to achieve #2, which is an important property. 

 

Does anyone have any ideas? I feel like I am too close to the problem and am overlooking something simple. 

 

PS: I understand that what I am talking about is, strictly speaking, a finite element method instead of a proper CA. However, I have repeatedly seen this referred to as a CA elsewhere, so I do so here as well.

0

Share this post


Link to post
Share on other sites
The four items you mention each require communication from cell to cell. That in turn requires communication through shared memory or mutlipass processing, both are difficult under Cuda / OpenCL.

Shared memory is fast and can be accessed between some nodes but not between other nodes. Global memory is slow. There are rules about coalescing data that must be followed.

If instead you write all the communication to buffers, consolidate them after main processing, and then run another pass, you will quickly become bandwidth limited on all but the most trivial of world sizes.


There are definitely some hurdles to overcome. These are patterns known to be difficult on GPU processing. The hardware was designed for something different. The farther you deviate from single-pass algorithms that read much data and output little data, the less likely you will be to see positive results.
0

Share this post


Link to post
Share on other sites

I should have been more specific! Yes I know about the memory architecture and how that causes this problem to be just "parallelizable" instead of "embarrassingly parallel".

 

http://www.olcf.ornl.gov/tutorials/cuda-game-of-life/

 

I was intended to use the second method shown there (the one using __syncthreads() & shared memory) as a rough template, and then maybe play around with texture memory or OpenCL later.

 

What I need help on was the CA design, not the programming. 

 

I frankly don't have the expertise to recreate that webGL interface. I also wonder how quickly it actually simulates erosion. Just waiting for precipitation causes very slow erosion, while adding water quickly saturates the landscape and results in smooth landscapes. 

 

http://www.world-machine.com/about.php?page=latest

 

Compare that to the images at the above page. The first one has a fairly obvious straight channel running diagonally from top left to bottom right. These result when your initial heightmap is smooth in that area. This means that taking a hand-made heightmap with a rough outline of your terrain and then eroding it can cause nasty artifacts. I consider that a nasty limitation of the extant techniques, as it removes much of the benefit of procedural generation.

 

While the webGL implementation and the second image in the WM link both have curvy river-like flow patterns, they are curvy because they simply followed the gradient of the input heightmap. They weren't caused by any interesting fluid/erosion dynamics. That is what I'd like to change, and that involves crafting the cells' update rules appropriately.

 

This involves simulating the flow gradient of the water in a persistent, non-stochastic way. What I am really asking for direction on is how to do that. 

 

PS: While the online demo is spiffy, non-real-time techniques are still useful. Because the erosion step dominates most terrain generation pipelines, if you can significantly reduce its duration then you open yourself to being able to completely procedurally generate large numbers of terrains. If you have some evaluation metric to compare them against, then you can select the best N of them to show to the artist, who can further tweak their parameters. These tweaked parameters can then be what is sent to the player, who generates the terrain on demand. This means that the amount of data which you ship to your end user to handle terrain is orders of magnitude smaller than it used to be, but still looks high quality because it has been hand-tweaked by an artist. 

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0