Search Unity

Erosion of a height map by shallow water simulation

Discussion in 'Made With Unity' started by scrawk, Jan 26, 2013.

  1. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Hey, this is a project I made in openGL but ported to unity as a learning exercise.
    I have no plans to use it for anything in the foreseeable future so thought I would upload the project for others to play with.

    It is a simulation of erosion on a height map by the shallow water model as out lined in this thesis

    View attachment $Fast Hydraulic Erosion.pdf

    It uses perlin noise to make a random height map for something to erode.

    The erosion algorithm is 100% done on the GPU via render textures so you will need unity pro.
    I guess you could move it to the CPU if you had the free unity version but performance would be poor.

    All shaders are heavily commented.

    EDIT - not working with opengl for some reason so will not work on mac. Exported form unity 4.
    EDIT - This probable should have been posted in WIP

    Project Files

    heres some screen shots

    $erosion0.jpg

    $erosion2.jpg

    $erosion3.jpg
     

    Attached Files:

    Last edited: Mar 25, 2013
  2. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Looks good, but I get many errors. (have you developed it for macos or unity4? I am using unity 3.5.7)

    $errors.JPG
     
    Last edited: Jan 26, 2013
  3. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    elias_t im guessing you mean " for mac"

    Sorry I forgot about checking for opengl compatiblity. When I add "#pragma only_renderers opengl" to the shader it will not run.
    Unity is not giving me any reasons why though. I will try and get in running on opengl soon.

    Looks like ARGBFloat render texture format was only added in version 4 so try changing it to ARGBHalf.
     
  4. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Thanks, I changed it already but I cannot open the scene because you made it with unity 4. I still use unity 3.5.7.
    I'll check again when I upgrade to unity4. Good work anyway.
     
  5. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    I just added a prefab to the project if you cant open the scene.
    Just create a new scene, delete the main camera and drag the erosionSim prefab from the prefab folder into scene.
     
  6. ZoomDomain

    ZoomDomain

    Joined:
    Aug 30, 2012
    Posts:
    150
    Hi there, very nice work! raintastic.

    did you attempt any variations regarding the width of the canyons and hardness of the rock? Limestone could make that kind of map, although most of the planet has height maps made of V shaped erosion pathways, with banks around 45' resulting in height maps that are dendrite fractal variety:
    Height map greyscale

    here is an interesting one also with perlin noise for the actual erosion.. please remember to answer if you wish because those are interesting links! You might forget!
    http://www.sciencedirect.com/science/article/pii/S0098300400001679
     
  7. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Hi ZoomDomain. Sorry I havnt been following this thread closely so only just saw you comment. The erosion model I used is rather simplistic and you wont get the full range of erosion effects that occur in nature. It does means its relatively fast and maps to the GPU easily.

    There are a bunch of settings hard coded in the shader (I know, not the best way to do it)

    Code (csharp):
    1. const float Kc = 0.04f; //sediment capacity constant
    2. const float Ks = 0.04f; //dissolving constant
    3. const float Kd = 0.04f; //deposition constant
    4. const float Ke = 0.01;  //evaporation constant
    5. const float Kr = 0.001; //rain constant
    Playing with these will give different results.

    That article looks fantastic. Will try and find a free copy or might just shell out the $20 for it. It uses quite a different technique from the look of it but results look great. May even make a Unity friendly version.