Voxel water like minecraft ?

hello, i have started a project which uses Voxels “cubes” similar to minecraft although the time has come where i need water … i have searched for ages to find evan a tutorial on this topic but no one has one …
the kind of water im trying to create is as seen hear :

from resent research ive found that many people used Cellular Automata but to be honest i have absoloutly no idea how to implement that into “water” if anyone would like to give me a hand with trying to create this or evan just give me some helpfull tips please feel free because i have no idea how im going to re create the water as seen in that video … :frowning:

  • Thanks …

This may help you understand what needs to be done…

This may be a start not 100% of what your trying to do but it may help you get going.

Hey thanks for the reply :slight_smile: i did infact check these out a while back but after the tutorial was over i kinda got lost and was unsure of where abouts to go from the way the water was done Thanks that link was fairly helpfull :slight_smile:

Minecraft only updates water blocks if something changes. One of the optimizations of Minecraft is there is no such thing as limited quantities of water (unlike, say, StarBound or Terraria where falling liquid drains the entire pool).

Say you have a block of water with blocks all around it. Now you remove one of those blocks. Minecraft then sends an “update” event to the blocks around the block that was removed. When the water receives the “update” event, it checks the surrounding blocks for air. If it finds air, it creates the first section of a waterfall in the air pocket. The new waterfall block then registers for an update after a small delay. After the delay, the waterfall block receives an update. It checks all the blocks around it. It finds an airpocket below itself and then creates a waterfall block below itself. The new waterfall block then registers for an update after a small delay…

and so on and so on.

What you want to do is have limited amounts of water which is a much more intensive process than Minecraft. Updating one block requires it to “flood fill” check every block connected to the body of water to adjust the water level.

1 Like

O

Ohh i see what you just Explained to me sounds Alot better … Thanks for the Great Response i might just try this out and see if i can acomplish it or not! … Thanks again That was Extremely Helpfull!

I know this is an old thread. As @PropositionOne said, you could use some kind of raycast system, which checks the block surrounding water in five directions (left, right, back, forw, down) you shouldn’t check the up direction unless your water climbs up.
I wouldn’t put that sort of function inside the Update() method, instead i would call it using events.
So if your terrain (I assume is procedurally generated) is modificated, it should call an event on every chunk saying thta the water blocks should check their surroundings, if a air block is found then use coroutines or Invoke(time) to check again, and again…
Also I would use some kind of mesh generator script, because instanciating 10000+ cubes is quite expensive
(i’d see this video:

which explains how to make a voxel mesh)
aaannd, dont forget abouts shaders, they literally can do miracles, idk put some refraction on it and it should look cool
if you do, share some screenshots i’d really like to see a working water system.
sorry for my english haha