I’ve been working on something for a personal project and am wondering if anyone would have any interest in this as a possible asset. Its a river creation extension for unity default terrain. It has two modes, painting water (in the video) and creating from a spline path (not shown). I’ve started to write 2 flow shaders, one toony (shown), and one realistic like unity’s built in water.
I’m still working on the flow mapping, but the concept is there.
Well, its a bit complicted. There are a couple of different methods. One, that many people use is to just make the mesh’s uvs tile so the water just follows the mesh. Its a good method, but it didn’t really give me the results that I wanted.
The method I used is a modified flowmap. Basically, the “river” is a grid of cells and each cell has a flow direction. The flow directions get averaged together with their neighbors so the flow is smooth. I make a single mesh from all of the cells and the flow direction is stored in vertex color. Then I animate the UVs based on the direction stored in the vertex colors. This method has a drawback in that the seams can be visible if your textures tile harshly because each cell can flow at a different rate of speed/direction. I get around this by using 3 textures. A base surface texture, and two flow textures, and then adjusting the “mix” of the textures so the seams are not visible.
here is a visualization of the flow direction grid. The arrows indicate the flow at any given point.
And this is an example of the same region in game, with test waterfall particles (i apologize for the quality, i recorded it smaller so it would upload quicker):
I haven’t given up. I’m working out a few finalizations, and adding a physics script so objects in the water follow the flow of the river. Currently I’m working on automatic smoothing of terrain. As you can see in the images above, the water seams are visible where I’m smoothing the terrain, and I’m trying to work that out so people don’t have to manually smooth the terrain border after painting the river.
Before using Unity, we spent some time with T3d. This was several years ago. They had a great river system, with physics as well. You could fall into the water and get washed off the edge of the world, something every one of our testers tried.
They used splines to create the rivers. Their textures were nice as well. I will admit that is the one thing I miss…along with the ability to place vegetation based on texture.
i’l follow this, your approach sounds interesting…
your vectors look wrong, speaking of flows…
altough speed vectors could help us making good shaders with turbulence effects
Correct. I’m only handling flow direction. Things like eddies and current are out of scope. I’ll need a different flowmap shader for that or the texture tiling would be terrible when things move with large speed differences. I will look into it, because it would be pretty cool.
After a brief 100 paragon level diablo 3 vacation, I finally got around to adding buoyancy and physics. Here’s a video of all of the current features. I just need to figure out editor undo stuff now.