Arnklit / Waterways

A tool to generate river meshes with flow and foam maps based on bezier curves.
https://github.com/Arnklit/WaterGenGodotDemo
MIT License
1.03k stars 68 forks source link

Physics based water system. #11

Open sairam4123 opened 3 years ago

sairam4123 commented 3 years ago

Is your feature request related to a problem? Please describe. The current waterways is static. I would love to see a dynamic water system.

Describe the solution you'd like A dynamic water system which flows from WaterSpawner to Ocean. Uses the heights of the HTerrain to flow from Mountain to Sea Level.

Arnklit commented 3 years ago

So you'd want the rivers to change at runtime? Because that will probably not happen. It's possible I might add the ability to have rivers be placed in the editor based on the terrain height.

sairam4123 commented 3 years ago

Well, not just Rivers, but Water flowing from upper gradient to lower gradient. It maybe a Stream, River, Lake, and even a Pond.

Arnklit commented 3 years ago

Probably won't happen. The calculations needed to make the mesh and the flowmaps is not something you could calculate every frame for a dynamic system. Waves when the player enters the water will probably happen.

I'll leave this open for now for any further discussion of the subject and we can revisit the discussion when I've finished the big rewrite of waterways I'm working on to make branching rivers and lakes possible.

TokisanGames commented 3 years ago

It appears you are requesting a realtime fluid simulation which is not only extremely difficult, it would be so cpu intensive as to leave little bandwidth for your actual game. This repository is also the wrong tool for this request. This tool creates a spline plane mesh with a realistic water shader on top of it. And it's really good at doing that. It is on par with the equivalent UE4 tool (pre 4.26).

Fluid simulation is incredibly impractical. I'm using this tool for a river, a lake and now a waterfall in a 3D ARPG on HTerrain. You don't need accurate physics. You need creativity and experimentation. If you need accurate fluid simulation, create it in blender and bake the animation. You'll have accurate physics, but incredibly high resolution meshes and animations.

sairam4123 commented 3 years ago

Well, I'm making a City Building game which allows for terrain changes, I'd love to have the water go up if the terrain above it changes, I'll take a look into Cities: Skylines again.

sairam4123 commented 2 years ago

It appears you are requesting a realtime fluid simulation which is not only extremely difficult, it would be so cpu intensive as to leave little bandwidth for your actual game.

it can be approximated with floodfill algorithm as stated by @Arnklit.

You don't need accurate physics. You need creativity and experimentation. If you need accurate fluid simulation, create it in blender and bake the animation. You'll have accurate physics, but incredibly high resolution meshes and animations.

The problem is, my game is dynamic, it's not static and I wouldn't be able to just use animations. But yep, the floodfill algorithm would be really helpful.

Arnklit commented 2 years ago

Yeah I'll leave this open for now. I think if I make a dynamic water system it will possibly be a separate asset.

This video @sairam4123 sent me shows the idea well. https://www.youtube.com/watch?v=rW8YZRtmTgo

As far as I can tell this should all be possible by using a high density water plane that gets displaced based on something like a floodfill algorithm that also takes terrain height into account to decide how the fill happens and uses the movement of the fill to drive the flowmap generation.

One of the problems with this is that it would be very interconnected with the terrain system and since Godot doesn't currently have a built-in terrain system, this kind of water system would have to be built around one of the terrain plugins.