Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Voxel Based Water

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 riuthamus   Moderators   


Posted 27 July 2012 - 03:04 AM

I am coming to this forum now since I have already posted my idea in the design concept and have a general idea of how I want the system to work. Thanks to a few posts there I have come up with an idea for how we can make voxel based water that does not suck like minecraft! I want to troubleshoot these concepts and see if they are even possible before I waste 40+ hours of my coders time doing something that would ultimately be horrible for our game.

Reference post for background information:

Goal of this project:
To create a voxel based water system that will give a decent feel of water simulation while not hogging resources. ( isnt that goal of everything? :( )

So the first thing to understand is what the current mindset is. I think the best option would be to create some way of defining ocean/source blocks from voxel shore water.

Posted Image

The dark blue would be your source blocks, and your light blue would be the voxel water filling in until it reaches full. Once the voxel shore water fills up it would become a source block. To save on resources we can limit how much one source block can spawn outward from an open face. This means you would need several source blocks to be able to get a wide area to fill up all the way and make more source blocks.

You might be asking, how do you plan on making this voxel based? The video from the previous topic in the design section showed an example of a cell based water system. If you understand the basics of art you can realize that everything we see is more or less a pixel and a pixel is simply a small block of color. You could use this understand to apply this to real world objects. Legos can look some serious shit if you build it big enough and you spend enough time with it. Why? because they are no different than the big portraits that we make they are pixel based ( assuming you understand the previously describe logic ). Using this knowledge we could apply the theory to our voxel system. If we were to break down each block into 8 sub parts we now have 8 pixels to display 3d water information with.

Posted Image

The dark blue would be your source block, and the light blue would be the voxel information of the water flowing out. As the water flows out the sub blocks would pop in and out as the water moved through that space. I can see several issues coming from this:
  • Water travel would have to be processed by the CPU or GPU, this could cause a serious strain on the system if several source blocks were to be in play. How much? not sure at this point as this is very theory based at this point in time.
  • We have an entire world to manage of upwards to 10milllion blocks. If we want to keep the premise of the game ( players can make what they wish ) while still providing a solid feeling ( high fps and responsiveness ) we are going to have to figure out a middle ground. This is not a water simulation game so we can not devote 100% CPU to rendering of it.
I am coming to this area of the forum to discuss what possible solutions we could use, if any. I hope I made this clear enough, if not let me know and we can go from there.

#2 Mito   Members   


Posted 27 July 2012 - 10:45 AM

Here i go again...

I've seen the link on your sign. the screenshot of you water gave me the following idea (when I say adjacent, keep in mind that I mean Adjacent AND in the same layer, i'm considering the 2d space of a layer):

all your water blocks start as source blocks.
whenever a block that is not a source block and is next to a source block gets updated, all the source blocks next to it are updated as well.

when a source block is updated, if there's a gap adjacent to it (i.e.: a block next to it was removed.), spawn a shore block on that gap. if there's less than 3 source blocks attached to the updated source block, the source block becomes a shore block. if a shore block has at least 3 source blocks adjacent to it, then it becomes a source block.

whenever a shore block has a source block directly above it, the shore block becomes a source block.

whenever a shore block has a gap next to it, spawn another shore block on that gap.

a shore block can regulate the water level on itself based on how many sources and shore blocks are next to it, as an example, you said you have 8 pixels, a shore block can only have 4 blocks next to it on the same layer, so let's say that for each source block next to the shore block, you paint 2 pixels and for each shore block you paint 1 pixel. whenever a shore block spawn another shore block, the original block loses 1 pixel, that is transferred to the new block.

if a shore block has no pixels drawn, it cease to exist.

you can do this in a way that you form a homogeneous line with your shore blocks, creating the curve effect that you want. updating the blocks only when another block get's updated can be tricky, but can save some CPU time. the trick here is to maintain the amount of data per block at a minimum.

i don't know if this helps, but is what I've in mind to solve your problem, hope this gives ideas to other people that can then help you better.

#3 kseh   Members   


Posted 27 July 2012 - 12:14 PM

Don't know if it's on the same path as you're going or if it's been mentioned before (I took a quick look and didn't see any mention) but I remember in an interview (here) Tarn Adams briefly discussed his flow model for Dwarf Fortress. Maybe there's some inspiration in there.

#4 laztrezort   Members   


Posted 27 July 2012 - 01:43 PM

Just spitballing a few things here:

A quick glance over the OP it looks like you are basically using a type of cellular automata, if that is the case then you could read this for some ideas: http://www.gamasutra..._automation.php

For optimizing, you will need to restrict the number of calculations that need to be made, there is really no other choice. This can be done by constraining the simulation to only those areas that need it and/or precalculating as much as possible.

I'm reaching on this one, but it also may be possible to memoize fluid calculations somehow (see here for example: http://en.wikipedia.org/wiki/Hashlife). If even applicable, this could greatly increase simulation speed (at the cost of memory obviously).

For determining feasability, the only way is probably to just bite the bullet and prototype the simulation.

#5 larspensjo   Members   


Posted 27 July 2012 - 03:23 PM

It may be that you are out on deep water here. If it is a voxel based game, with a very large world, it usually means the game engine has to be able to load or create only needed parts of the world (sometimes called chunks).

In such a world, it is difficult to use any algorithms that depend on adjacent blocks. Suppose you have a chunk 'A' adjacent to 'B'. But to be able to find out how water behaves in A near B, you also need to load B. But that may require loading of all adjacent chunks to 'B', or you can't compute how B looks.

It is possible to handle, but no easy thing.

Just for fun, my voxel based world. Everything including the water, is blocks, but drawn smooth:
Current project: Ephenation.
Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/

#6 riuthamus   Moderators   


Posted 27 July 2012 - 03:28 PM

While true, the only thing that matters is what the client sees. The server is a total different thing. Not with netcode yet so not sure exactly how that will play itself out. You can reduce some load by the way you draw objects and faces. This is why we have a view limitation. Good points though and I will make sure that Michael keeps that in mind when making the system. Thank you all for the feedback. Once we try some of these or we fail I will let you know! Really, thanks!

#7 EVIL_ENT   Members   


Posted 28 July 2012 - 05:55 AM

A search for "tall cell grid" might turn up helpful results (there are a few papers about it)
You could even do real water simulations with it, e.g. this

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.