Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Voxel Water in c# ?

Discussion in 'Scripting' started by Endzone, Mar 13, 2016.

  1. Endzone

    Endzone

    Joined:
    Dec 18, 2014
    Posts:
    119
    Hello, I had a few questions and was wondering if anyone had answers. Im trying to create voxel water as seen in this video:

    But im not sure how to go about it, i had a few ideas but im not exactly sure my ideas would be very efficient to do such a thing. i did try to get incontact with the creator of the voxel water in the video but i had no luck, If anyone knows how this can be achieved i would love to hear it!
    - Thanks
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    How familiar are you with voxels? It looks like a standard voxel implementation with a simple flow diffusion model. It also appears to follow the normal voxel physics trick of turning off physics once the interaction is over.
     
    Last edited: Mar 13, 2016
  3. Endzone

    Endzone

    Joined:
    Dec 18, 2014
    Posts:
    119
    Vowels? vixen implementation? to be completely honest i have no clue what you mean, ive only been coding for about 1 year so theirs still Alot i dont know could you please Explain :S ?
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Sorry that should have been voxels. Damn autocorrect. It reads better now.
     
  5. Endzone

    Endzone

    Joined:
    Dec 18, 2014
    Posts:
    119
    Ohh i see hahah i thought so but then again just to be sure i thought ide ask :D, im fairly familiar with Voxels the last 7 months i have dedicated to my own voxel game, i had an idea to make seperate blocks "voxels" that where just simply different heights with some sort of water shader ofcourse and then instantiate / delete the different blocks as i needed them but that would require me to code every possible outcome when a water block is placed and it didnt seem like a very efficient way to go about it, i then had an idea to create a voxel that had a float value which would be its water value and then just match up the blocks size to its water value and then make a bunch of if() statements to check around the water block and change its water value accordingly but that yet again didnt seem to be a very efficient way of doing it, but idk those where the only two ideas i could come up with that seemed like a viable way to go about making this water.. :S
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You want to seperate the flow of water from its representation. I would represent water by making a voxel with an extra float parameter for its height. Then just draw it like a regular voxel.

    For flow I would simply compare the height of water at each voxel with the height around it, and adjust accordingly. Once the water is below a minimum height then stop checking for flow.