Search Unity

Rivers that follow terrain

Discussion in 'World Building' started by Hondacar1212, Jun 17, 2019.

  1. Hondacar1212

    Hondacar1212

    Joined:
    Nov 26, 2017
    Posts:
    17
    Hello,
    I am currently working on a map and I have the design down for the most part (if anyone wants to see it I will gladly post a picture of it).
    What I as m trying to figure out is the best way to have a river that flows from the source, down the terrain, and into the ocean.
    I tried using a particle system, which kind of works, but it has to detect every collision with the terrain and other particles. As you can imagine , that causes a huge slowdown and is not performant at all.

    I looked into a mesh and flow map, however making a river mesh is difficult due to the terrain (lake, flow, waterfall, lake, flow ocean.

    I was hoping to find a solution similar to Cities Skylines, where you can place a source and the water does what it does.
    I found a Reddit thread about it where they were saying it's most likely a particle system, procedural flow maps and shader magic.

    I started looking into Navier Stokes equations because my research led me there, and while it seems intriguing, I don't think I can use anything like that in Unity.

    I was thinking maybe turn the entire heightmap into a flowmap, then making river meshes, although I'm not entirely sure how to accomplish that either.

    What is the best looking, and most simple method to achieve a river flow?

    Thanks in advance.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    Depends what level of visual fidelity you want.

    If you're content with simple, just make a long depression in the terrain and fill it with a long snaking mesh that is your river surface water. Now animate the texture so the water flows downstream.

    Extra points: deform the verts of this "river strip" up and down to simulate waves.
     
  3. Hondacar1212

    Hondacar1212

    Joined:
    Nov 26, 2017
    Posts:
    17

    I guess simple wasn't the right word, as simple could mean just using the built in water and calling it a day. I don't really want to "invent" a water system (if that makes sense), but I want it to look like flowing river water. I tried animating a texture on a plane from blender, although I had trouble getting the water level height right. I also had some trouble animating where the river would double back on itself.
    That's where the flow map shader idea came in, I'm just not sure how to make a large scale flowmap that would cover the entire river.

    Long story short a believable looking river where a trickle builds to a stream, to a giant river as it picks up other water sources.
    As cool as a dynamic river system sounds, that's way beyond my current skill level.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,697
    With ECS and DOTS coming out, if you're looking to do some high-computation particle flow field simulations, I guess that would be the tech stack to reach for, especially if you're going to have runtime placement and processing of rivers, versus the traditional "make an animated river in advance" method.

    As far as games that have rivers/lakes/oceans in them, I cannot think of a single game I have ever played where I thought the game would actually play better if the water was more realistic. Water is either off-limits, or just another part of where your player can go.

    Even Wetrix back on the N64 was "good enough," and in that case the water was an integral part of the gameplay, rather than just scenery.

    Your mileage may vary... good luck!
     
  5. Hondacar1212

    Hondacar1212

    Joined:
    Nov 26, 2017
    Posts:
    17
    Thanks for the advice, I'll keep working with an animated texture. I'm sure that my previous attempt was by far not right.
     
  6. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,274
    You can use RAM 2019 for that. I tried it recently. Here I set the source on the top of the terrain and hit the simulate button. The spline was generated automatically down thee terrain. I adjusted the width though afterwards (I already put in a feature request for that).

    ram.jpg
     
    wyattt_, Hondacar1212 and Kurt-Dekker like this.
  7. YetAnotherKen

    YetAnotherKen

    Joined:
    Jun 17, 2019
    Posts:
    30
  8. wyattt_

    wyattt_

    Unity Technologies

    Joined:
    May 9, 2018
    Posts:
    424
    What are you using to generate your terrain?
     
  9. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,274
    I use World Creator 2 Professional, the Standalone version:

    https://www.world-creator.com/

    It's really awesome and intuitive. And of course your terrain tools after I imported the WC2 terrain as a base. Either your shaping tools or the Stamp Tool with stamps which in turn I created in WC2.

    ps: fyi, World Creator 2 Standalone is built with Unity :D
     
    Last edited: Jul 3, 2019