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. Dismiss Notice

Liquid Voxels

Discussion in 'Works In Progress - Archive' started by Ellandar, Apr 26, 2014.

  1. TheXWolf

    TheXWolf

    Joined:
    Dec 13, 2013
    Posts:
    85
    I imported everything verbatim, and while the test scene loads, I get a null ref error every frame.
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. LiquidVoxelsSim.LiquidVoxels.LocationIsValidInVoxelWorld (Vector3 worldLocation) (at Assets/LiquidVoxels/Scripts/LiquidVoxels.cs:297)
    3. LiquidVoxelsSim.LiquidVoxels.AddVoxelTypeToLocation (VoxelType objectToAdd, Vector3 worldLocation, Int32 volumeOfLiquidToAdd, Boolean replaceExistingType) (at Assets/LiquidVoxels/Scripts/LiquidVoxels.cs:202)
    4. WaterSpawner.Update () (at Assets/LiquidVoxels/Scripts/Tools/WaterSpawner.cs:42)
    5.  
    I also noticed however that beneath the Liquid Voxels script on the GO, there's a missing script between Liquid Voxels
    above Water Physics. Maybe something gets messed up when imported to unity. (Using 5.1.1.f1)

    Either way I'm looking forward to using this, decided to use Uniblocks for the project.
     
  2. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Hi TheXWolf,
    I haven't tried it on 5.1.1 yet, I'll have to give it a go.
    Is there a UniblocksComms component on the gameobject? It sounds like it's missing that; although I swear there were checks in the system to yell loudly if there wasn't.

    It's currently work hours here in Aus, so I'll take a look tonight when I get home and let you know what I find.

    -Ell
     
  3. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Hi TheXWolf,

    I setup a brand new scene and was able to reproduce what you were seeing. The reason you see that error is as suspected, you don't have the Uniblocks Voxel Comms script attached to the LiquidVoxels Object.

    Go into Assets -> LiquidVoxels -> Scripts -> VoxelEngineInterfaces. Double click on "Uniblocks" and let it unpack.
    Go into the Uniblocks directory under VoxelEngineInterfaces and drag the UniblocksVoxelComms into the missing monobehaviour area.

    Make sure the steps are followed here or you'll run into other problems after that.

    - Ell
     
  4. Revek

    Revek

    Joined:
    Apr 11, 2012
    Posts:
    14
    When you put this on the asset store, will you have the option for smooth voxels included?

    Also I am looking for a particle solution that works with circular gravity asset, is it possible to make these voxels into particles? (smoke from flex)
     
  5. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    G'day Revek,

    Smooth Voxels comes with it's own set of challenges which I won't have ready for 1.0. It will be a later release though, as I have a proof of concept already working but it's nowhere near ready for public consumption.

    As for particles, the system as it is now can create particle emitters in each location instead of rendering a voxel block, but I have to warn you that it is very CPU/GPU intensive as you could end up with a LOT of particle emitters.

    Under Assets -> Liquid Voxels -> Scripts -> Plugins there's a script called "RenderGameObject". Add that and remove your other renderer (RenderInTerrain by default). I haven't tested RenderGameObject for quite a few months as it was just a thought experiment, but I left it there in case someone found a use for it.
    Edit: Also, once the "RenderGameObject" component has been added, you'll need to drag your particle emitter into the field for it, otherwise it will split out errors saying there's no GO to instantiate.

    Let me know how it goes and if you have issues.

    - Ell
     
    Last edited: Aug 10, 2015
  6. TheXWolf

    TheXWolf

    Joined:
    Dec 13, 2013
    Posts:
    85
    @Ellandar
    Works perfect now thank you. I have a question though, is there anyway with uniblocks to assign a different shader to the water so that I can animate it? I have a simple shader for tiling a texture for liquids, but your system pulls from the normal sheet correct?
     
  7. ironbellystudios

    ironbellystudios

    Joined:
    Jul 21, 2015
    Posts:
    410
    How long before someone makes Dwarf Fortress in 3d with this? Or has someone already done it :D (Did you just flood your castle with Lava? Woops.)
     
  8. TheXWolf

    TheXWolf

    Joined:
    Dec 13, 2013
    Posts:
    85
    Oh you have no idea oh tempted I am just to put the demo block in a giant hollow hole and see if I can flood the world the way I do with minecraft/buildcraft lol. Now this essentially creates a block the way uniblocks does, so I could technically apply a script to the liquid block if it's lava or water etc. to produce logic correct?
     
  9. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    Looks awesome :)
     
  10. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Glad it worked! The shader side is completely in the uniblocks side and from what I can see at this post from Maap it's not something uniblocks supports. This is now incorrect!

    Maap has supplied a way to do this by using multiple materials as per this post. Check the uniblocks doco and see how it goes.

    The way I approached it when using cubiquity is described in this post a few pages back (with an example in the post before it), if you set up a new project with cubiquity you can see it all in action by opening the scene: Clouds and Waterfall.

    The way I did it was to basically run 2 voxel instances of cubiquity in exactly the same location, one dedicated to terrain and the other to water. I then wrote a IVoxelComms interface that sampled both terrains when asked to "Get" a voxel, and only wrote to the dedicated water terrain when doing a "Set" voxel. Then I was free to write a special renderer for the water terrain so it looked good, I was also able to do some other optimising things like turn off colliders in the water to make things run faster.

    My system interacts with Uniblocks in exactly the same way your game would; via the uniblocks API, so if you can write a shader that works normally for uniblocks but treats the uniblocks water block (or lava/mud/whatever you are simulating) differently then it would 100% work with Liquid Voxels.

    The rendering side of Liquid Voxels relies 100% on the voxel engine it's being run in. As I mentioned earlier, you can ignore the voxel engine when rendering and spawn gameobjects too if you like, it's up to you.

    - Ell
     
    Last edited: Aug 11, 2015
  11. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Lol, that I would LOVE to see!

    I'm finding the biggest challenge in this is the unity mesh support; updating a mesh a LOT is not a strength of unity so I'm having to come up with creative ways to reduce update load on the voxel engines we interface with. The go-to method i'm using is to buffer calls and remove duplicate calls, it's working so far :)
     
  12. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Thanks. I'd like it to be awesome-erer but I guess I have to stop trying to make it awesomer at some point and make it available on the store :)
     
  13. Sykoo

    Sykoo

    Joined:
    Jul 25, 2014
    Posts:
    1,394
    Haha, true! :)
    You maybe could think about an initial release, and then keep updating!
     
  14. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    As Dr Farnsworth would say, Great news everybody!

    I just checked in Save/Load functions. It's had a grand total of 3 tests so far so it's likely very buggy and it's also slow. But it's there! It turned out to not be a huge thing to add, it was just quite tricky and required a little bit of lateral thinking.

    I now consider LiquidVoxels to be basically feature complete for version 1, so there'll be a new Beta release in the next week (depending on how much time it takes to clean things up and create a release) and I'll start taking bug reports. I have a few things to do to round out in the Save/Load which I'll release as I go for people to test.

    I'll not be adding brand new features until after release unless it's an obvious missing thing, like being unable to add new liquid to the simulator etc.

    - Ell
     
  15. TheXWolf

    TheXWolf

    Joined:
    Dec 13, 2013
    Posts:
    85
    @Ellandar
    Awesome to hear! Can't wait to test it out. I wanted to also let anyone who might be using it with Uniblocks that as Eli mentioned and is mentioned in the Uniblocks thread, I started using this system with a texture set on a seperate tile sheet and shader, and they actually work just fine. :cool:
     
  16. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    @TheXWolf
    Do you have some screenshots you could share? Keen to see what you have come up with.

    -Ell
     
  17. TheXWolf

    TheXWolf

    Joined:
    Dec 13, 2013
    Posts:
    85
    Sure, I'll need to take it into blender or 3ds to play with UV warping as the corners don't match up, not sure how to fit that into Uniblocks yet, but one problem at a time lol. Here's what I did with having stuff on a separate sheet...It's a different material with it's own shader and only a single texture, so it's added to the material array in the chunk manager. ;)
     

    Attached Files:

  18. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Looks good.

    How are you finding the simulator in Uniblocks, or even the simulator in general?
    I have to admit I haven't used the simulator to create much more than a very simple game.

    - Ell
     
  19. TheXWolf

    TheXWolf

    Joined:
    Dec 13, 2013
    Posts:
    85
    It's actually not bad at all, there's a lot of clipping from one position to the next, so that's something to think over. Comparing it to water from MC, or starbound/terrarria there's a bit more that can be done, but for what you've done so far I like it. My biggest issue is I can do just about anything with a plane or water area but as for liquid that actually moves and can reshape I don't know what system to use.
     
  20. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Thanks for the feedback.

    Yes, that flipping between positions is something that needs looking at. I could address it with another pass over the simulation algorithm itself, so something I'm likely to leave till after release.

    Use mine :)

    But yes I agree, water areas are very well handled via a plane and a nice shader. I'm going to need some smarter sleep code to handle large areas of water. Once that's sorted though, the simulator will basically ignore large areas of water unless a block next to it changes and the edge of the water wakes up allowing it to flow again. Seems to be the best of both worlds (large areas of static water + dynamic if something happens to it).

    -Ell
     
  21. TheXWolf

    TheXWolf

    Joined:
    Dec 13, 2013
    Posts:
    85
    If you manage to get both of those features to work, not only would it be amazing, it would beat out any water resource I've seen thus far, inside unity or out. My biggest brick wall in the road is trying to figure out how I want water to work for large and small areas. Even with the choppy-ness of your system I am using it for the time being, just because I want water that moves lol. :cool:
     
  22. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,321
    So where can I get this?
     
  23. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Hi @leegod The first post has the latest beta in it: Beta 1.01
    I've been super lazy and haven't packaged and released the latest versions (which are hyper buggy at the moment).
    Sporadically working on the plugin but I have to admit I've really not put a huge amount of time into it lately.

    - Ell
     
  24. killer1171090

    killer1171090

    Joined:
    Feb 23, 2013
    Posts:
    145
    Any Update? I'm hoping to be able to use this in my game, I'm using Voxeland.
     
  25. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Hi @killer1171090 I haven't updated this for a long, long time.
    I burnt out at work. When I managed to recover I realised I was taking on too much and this one one of the things attributing to the burnout.

    Things are a better at work and I've actually been looking through the LV code this past few weeks wondering if I should revive it again.
    What were you planning on using it for in your game? Large lakes, flowing water, rain, puddles etc? Just wondering as the posted version of the simulator isn't too bad at most of those things. Flowing water is probably going to need something other than CA for it to look really good.

    - Ell
     
  26. killer1171090

    killer1171090

    Joined:
    Feb 23, 2013
    Posts:
    145
    I intend to have large lakes, rivers and Oceans. if possible. I only really need a script to make this work with voxeland. I should be able todo the rest from there.
    I may do rain but it would be very minimal, only a few puddles appearing every few minutes of rain.
    I mostly want this to be able to flood caves and add a challange to players.
     
    Last edited: Jul 4, 2017
  27. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    This might work with voxeland, I've never tried it. If voxeland has a 'water' block then you can likely write a quick interface for it in liquid voxels and see if it runs. Look at the existing interfaces (inherits iVoxelComms) to see what is needed, but it's quite light in what it requires. The complexity comes when you try to make things faster by caching and stuff like that.

    - Ell
     
  28. EuanHollidge

    EuanHollidge

    Joined:
    Nov 3, 2014
    Posts:
    69
    Has anyone ever got this working for smooth water and not just cubic? And did this ever make it to the asset store?