Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Voxels! - Introducing Cubiquity, a voxel plugin built with C++ and PolyVox

Discussion in 'Works In Progress - Archive' started by DavidWilliams, Apr 29, 2013.

  1. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    This thread has moved! Cubiquity for Unity3D has been released so future discussion will be held in our thread in the 'Assets and Asset Store' forum.

    About Cubiquity
    Cubiquity is a flexible and powerful voxel engine for both the free and pro versions of Unity. It can be used to create terrains with caves and overhangs that can be edited in real time, or to create retro-style environments from millions of colored cubes.



     
    Last edited: Sep 3, 2014
  2. GBCFraser

    GBCFraser

    Joined:
    Apr 11, 2013
    Posts:
    94
    I would be interested in the planet generator. I would use something like this to pull a skyrim; procedurally generated levels with a hand touch finish. How much would this kind of middleware cost?
     
  3. scrawk

    scrawk

    Joined:
    Nov 22, 2012
    Posts:
    804
    Looks amazing. Voxels are quite a popular topic around here so Im guessing you will get a big response from the Unity community.
     
  4. GeneBox

    GeneBox

    Joined:
    Nov 15, 2012
    Posts:
    480
    Looking great!
     
  5. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Thanks guys :)

    Sorry, but I'm afraid that's not a planet generator. It's actually just a Mandelbulb (a 3D version of the Mandelbrot fractal). We needed some large data sets for testing purposes and fractals provide a nice way of generating these while still keeping lots of detail.

    There may be a procedural generator in the future (or at least an example of how it's done) but for now we will focus on getting the core working nicely and providing tools for manually sculpting and editing the terrain.

    We haven't exactly worked it out yet. For the full system we will probably be looking at upper end of the price range on the asset store, but we would also like to offer a free version under some kind of personal or non-commercial license. I don't know whether the asset store allows this kind of restriction though so it's something we have to think about.
     
    Last edited: Apr 30, 2013
  6. Crunch2600

    Crunch2600

    Joined:
    Mar 1, 2013
    Posts:
    5
    This seems promising! I'll be sure to follow your progress.
     
  7. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    *** Update - 20th May 2013 ***

    We've been hard at work on our Cubiquity voxel plugin for the last couple of weeks. In our initial announcement the voxel environment was completely static, but it can now be modified in real time. The screenshot below shows some physics object bouncing around the environment while we cut holes in it:


    The physics integration also let us create a very basic test game where you can drive a tank around an arena and shoot holes in the walls. This relies on raycasting through the voxel data and this is also performed by the underlying Cubiquity engine. Naturally you can shoot out the floor and then fall through it :)


    We're keen to get a preview 'proof-of-concept' release out soon (next couple of weeks?) though initially it will only have an interface for programmers. 'Edit mode' support is something we'll add later.
     
  8. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    *** Update - 21st June 2013 ***
    Hi guys,

    We've released a new test version showing the integration with Unity's physics engine. You can now destroy chunks of the environment and have debris bounce around the terrain. Check it out in the video below:

    [video=youtube_share;d5RjcXvDMeY]http://youtu.be/d5RjcXvDMeY

    More details and a download are here:

    Please also note that we now have a thread in the 'Assets and Asset Store' forum as a preview of the software is now available for download. That thread will probably be more active but I'll post updates here as well to make sure they don't get missed :)
     
    Last edited: Jun 21, 2013
  9. DaneC020

    DaneC020

    Joined:
    Mar 19, 2010
    Posts:
    191
    Looking really good! Runs pretty smooth on my old Core 2 Duo. If I blow up too many items and the draw calls get above 1000, then I start to see 15fps. Otherwise I am above 32fps all the time.

    -Dane
     
  10. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Great, I'm glad it works well for you. Did you have to change anything to make it run or did it just work? Also, are you using Unity Free or Pro? I was a little concerned that the native code .dll wouldn't load on other people machines, as I only tested on my dev machine.
     
  11. DaneC020

    DaneC020

    Joined:
    Mar 19, 2010
    Posts:
    191
    I am running unity pro and I didnt experiences any problems when loading it. I had loaded the project and then loaded the volume data as per the instructions. Then I hit play and everything worked fine. I had not tried playing around too much as of yet, but everything ran well.

    Dane
     
  12. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    Looks amazing, kind of reminds me of minecraft
     
    Last edited: Jun 24, 2013
  13. Frostbite23

    Frostbite23

    Joined:
    Mar 8, 2013
    Posts:
    458
    And also if you go to the edge of the voxel map, will it automatically load more to the voxel map?
     
  14. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Thanks :)

    At the moment it does not automatically load new sections of the map - we do have some support for this inside our C++ code but it's not finished and still needs to be exposed to Unity.

    Eventually we would like to implement this feature to support large maps (thousands of voxels in each dimension). We're not currently aiming for 'infinite' maps though, unless there seems to be some demand for it.
     
  15. chrisall76

    chrisall76

    Joined:
    May 19, 2012
    Posts:
    667
    Infinite would be cool, but Minecraft shows that after a while exploring it can get a bit buggy when it comes to infinite. Large world sizes/sizes we could set would work.
     
  16. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    I'm going to have to hang my head and admit that I haven't actually played Minecraft :oops:

    Would you say that Minecraft really benefits from the infinite terrain? I mean, I can understand that the world needs to be big and that the player shouldn't reach the edge of it, but surely a very large terrain would accomplish this as well. Practically speaking, how far do players travel from their start point? Perhaps it's psychological - that the player feels more inclined to explore if they know the world goes on forever?

    Anyway, I do think that voxel terrain is often associated with infinite terrain (and also with procedural generation) so we should probably keep that in mind.
     
  17. Psyckosama

    Psyckosama

    Joined:
    Mar 20, 2013
    Posts:
    88
    This looks good, its just a shame its in C++. C# would have permitted people without Pro to make use of it.

    Is there going to be any level of liquid sim or biome generation?
     
  18. DaneC020

    DaneC020

    Joined:
    Mar 19, 2010
    Posts:
    191
    @DavidWilliams

    Don't feel bad! I haven't played Minecraft either and I love working on voxel code! It is a hobby of mine but I just never had the appeal to go and play Minecraft.

    -Dane
     
  19. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Actually this system does work with Unity Free! I know this because I have Unity Free myself :)

    There seems to be a lot of confusion about the capabilities of Unity in the regard. My current understanding (see here) is that 'native code' is not the same as a 'plugin'. All plugins are native code but the reverse is not true. So Unity Free does seem to support the loading and execution of native code in .dlls, but you can't use the 'Low-level Native Plugin Interface' unless you have Pro.

    The restriction seems to be aimed at preventing users from extending the rendering capabilities of Unity Free through plugins, as this would allow users to add things like shadows which are supposed to be Pro only. But this voxel terrain isn't really a rendering feature - it's just generating the mesh and adding it to the Unity scenegraph.

    Anyway, there's a download in my last blog post so feel free to give it a try. If anyone at Unity wants to really clarify the situation then that would be appreciated.

    Yes, but these things will be provided as examples rather than as core features.

    The programming interface to this system is really simple. It basically provides a function to create a volume, and then a couple more functions to get and set the colours of individual cubes. Anything higher level than that will simply be provided as examples (or maybe higher level frameworks), building off existing extensions where possible.

    For example, Unity already has extensions for both fluid simulation and for procedural generation. You just need to know how to integrate these into the voxel system, and then you have a lot of flexibility over what kind of game you will create.

    Yep, I feel the real world would be a better place if it was made of voxels :cool:
     
  20. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Hey guys,

    Over the last couple of weeks we've mostly ben doing back-end work (optimisations, mamorry-managment, etc) but we now have some cool new screenshots to show! We've used the awesome Detonator asset for Unity to add some really nice explosions, which go well with our destructible environment. We've also loaded in a new map (courtesy of 'Influx' on the Build Shoot forums) and got a better tank model from the asset store. Check it out!





    Driving round and shooting up this environment is really fun :) I'll make a video and demo in the coming few days.
     
    Last edited: Jul 12, 2013
  21. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    *** Update - 18th July 2013 ***

    We've been hard at work for the last few weeks and can now bring you an updated video and playable demo! For this version we have imported a map from the game Build Shoot, integrated explosions from the Detonator package, and get a new tank model from the asset store. The result is a very cool and fully destructible environment for you to play around in!

    [video=youtube_share;rhV2dcM4IkE]http://youtu.be/rhV2dcM4IkE​



    You can download the standalone demo here: Download demo

    There's also more details on our blog, and some thoughts about what we are going to do next in terms of letting you guys play with this technology: http://www.volumesoffun.com/more-progress-with-the-unity3d-integration/
     
  22. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Dynamic shadows are now available in Unity Free :) They provide a great way of doing lighting in voxel-based scenes because they can cope with modifications to the environment:



     
  23. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Hey guys,

    Over the last few months we have gained a lot of insight into where we are going with this project. Therefore I have taken the time to rewrite our original post with more details about our current plans. So if you are interested in this project then please go back and read that first post again as it's full of new information!

    As always, just ask if anything isn't clear.
     
  24. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    We're getting very close to making an initial public release of the code now - I think it will happen in the next week or so. I'm trying to make sure that the core functionality and correct architecture are in place.

    It's now possible to perform basic editing of the voxel data from within the Unity editor. This is currently just adding, removing and coloring voxels, but higher level functionality (line drawing, flood fill, etc) can build upon this later.

    I've also added a quick example of procedural generation. Note that this is just an example - it shows how to set the voxel data from a script but we expect users will implement their own procedural generation in a style which is appropriate for their game. We've shown a landscape here, but you could also generate cities, dungeons, etc.



     
  25. DaneC020

    DaneC020

    Joined:
    Mar 19, 2010
    Posts:
    191
    Looking really nice. Any performance testing been done yet with the system? Curious what we are looking at for chunk generation and chunk updates.

    -Dane
     
  26. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Thanks :) I must say, I still haven't done any real performance testing. However, I can tell you that every time the user switches from edit mode to play mode the entire volume is reloaded and the mesh is regenerated. On my fast desktop machine this takes about four seconds for the 512x512x64 'industry' map shown in the last video. My back-of-the-envelope calculations indicate that this is about 7ms per 32x32x32 chunk.

    I'll have to test it on my laptop to see how it performs there - I think it was a lot slower but I was also able to reduce the chunk size to still allow mostly real-time modification.

    Overall, the only performance problem I've really encountered is the simulation of a large number of cubes which are spawned when the environment is destroyed. You can easily end up with hundreds bouncing around the scene and this takes a toll on the framerate. Actually I don't think they are batched so it could be a draw-call limitation here... I have to look into it.
     
  27. HeadClot88

    HeadClot88

    Joined:
    Jul 3, 2012
    Posts:
    736
    Hey - Question - Will we be able to convert pre-existing 3D Meshes into Voxel data?
     
  28. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Eventually yes, but this feature is not yet implemented. I suspect it will be implemented as a separate tool which voxelizes a mesh into a series of image slices (see this post) which can then be imported into the engine. It will probably voxelize standard mesh formats (.obj, .fbx, etc) rather than Unity meshes as the C++ part of our system is engine independent.
     
  29. HeadClot88

    HeadClot88

    Joined:
    Jul 3, 2012
    Posts:
    736
    Awesome!

    Now when can I start throwing money at you?
     
  30. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    I think we'll start selling licenses towards the end of the year, but if people want early access to test the system then in principle this is possible as soon as we make our first public release next week.

    The Unity integration code will be public in BitBucket, and will come with a native .dll with hard-coded limitations on the size of the volume. So all we really have to do is swap the .dll for another one without the size limitations.
     
  31. HeadClot88

    HeadClot88

    Joined:
    Jul 3, 2012
    Posts:
    736
    Will we be able to use multiple voxel volumes instead of one giant big one?

    EDIT:

    When you say next week - do you mean the 19th to the 23rd of august or the 26th to the 30th? Sorry I am a bit confused.

    Now - I have a few more questions about your plugin.

    1. Is Cubiquity it compatible with the MacOSX and Linux Export of unity? What about the android export? or is that planned?

    2. Can we assign custom properties to specific voxel volumes/Voxels? For example specific voxels are explosive and others are heavier and others cannot be destroyed with out a special weapon?

    3. How is performance memory and CPU wise? Could this run on a mobile device such as a OUYA or Nvidia Sheild?
     
    Last edited: Aug 18, 2013
  32. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Eventually yes, but it's not implemented at the moment. Ideally this would be behave naturally and volumes would be able to be translated, scaled, and rotated. Actually the rendering aspect of this shouldn't be too hard, but raycasting/picking may be slightly more complex. The free version would also limit the number of volumes which can be created.

    We're shooting for the week of 19th-23rd August for the inital release.

    Because Cubiquity is a native code library it needs to be compiled seperately for each of those platforms. This is possible (and desirable) but it is some extra work on our part. For example, to build/test on MacOS we need a MacOS machine which we don't currently have.

    So initialliy it's Windows only, with other platforms coming in the future. We'll probably try to get the Windows version more polished first.

    Not at the moment, you can only create an instance of 'ColoredCubesVolume' which stores a single color per voxel. I expect in the future it will be possible to create a seperate volume with a custom struct for each voxel, and use that for such information. But again this isn't currently high priority (after this release our next focus will be to get smooth Marching Cubes terrain working).

    Haven't done much testing here, but we hope the use of native code will give both performance and memory advantages. We did briefly test the engine on a mobile phone using Gameplay3D instead of Unity: https://www.youtube.com/watch?v=g9Gv0IFCMKc
     
  33. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Last edited: Aug 23, 2013
  34. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Ok, this is pretty cool... the code has only been available for a few days and already it has been used for the Ludum Dare competition :)

    CubePocalypse was made in only 48 hours by one of our users. Most Ludum Dare games are a little rough round the edges, but it's very playable an quite fun. You have to run around the map to reach the altar (identified by the blue beam going into the sky) before the timer reaches zero and it randomly moves. All while avoiding the meteorites raining down from the sky!

    Here's some screenshots:

    $27493-shot0.jpg

    $27493-shot1.png

    $27493-shot4.png

    More details and the download are available on the Ludum Dare page. Do let us know if you create anything else with the engine!
     
    Last edited: Aug 27, 2013
  35. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    The Cubiquity engine supports smooth voxel terrain based on the Marching Cubes algorithm, as well as the 'colored cubes' voxels shown previously. This lets you sculpt natural looking terrains and I've just started exposing it to the editor :)



    It's already in BitBucket, though it's highly experimental and will remain so for a few weeks.
     
  36. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    I've spent some time playing with the sculpting tool and trying to get it to feel natural. As with the Unity terrains, it should be possible to adjust the brush sizes and brush opacity to give maximum control. We will take other cues from the Unity terrain interface as well - there will be options for raise and lower (though in our case they are working in all three dimensions, so it's more like 'push' and 'pull') and also a smoothing capability.

    Anyway, here's another terrain I sculpted. You can tell it's full 3D (not just a heightmap) by the cave in the mountain, the bridges over the water and the... erm... slightly odd looking structure in the corner of the map. It's also showing a skybox and Unity's built-in water plane.

    $Sculpt1.jpg

    $Sculpt2.jpg

    Again, you can already download and play with it as the code is in BitBucket. Lot's of work still needed on the user interface though! I'll make a video in the coming week for those who aren't brave enough to actually try it yet :)
     
  37. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    wow very nice

    thanks!

    and thanks for letting me in on Detonator!
     
    Last edited: Sep 2, 2013
  38. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    So can I develop on windows and deploy to android ?
    Or can I only deploy to windows
     
  39. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    At the moment the you can only develop on and deploy to Windows, due to the dependency on the native code library. There's nothing stopping us bringing this native code library to other platforms (except we don't own a Mac), we just haven't done it yet. I think we will wait until everything is a bit more mature before taking this step.
     
  40. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    We got around to making a video showing the smooth voxel terrain sculpting inside the Unity3D editor. Check it out below!


    There's more information in our latest blog post, and don't forget that very early code is already available in BitBucket.

    Next we'll be adding the ability to paint textures onto your sculpted terrains... so stay tuned!
     
  41. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    This is a very cool plugin , but the lack of support for Android and IOS is a bit of a deal breaker, is their anyway to rewrite this to run in Unity directly.
     
  42. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    I expect that eventually the system will run on all platforms which Unity supports, except for the webplayer (as there is no way to use native code from the webplayer). In all cases it is necessary for us to build the native code library for the required platform and then provide it to the user. We will do this once the whole system is a bit more stable and mature (I know the screenshots look nice but there's still a lot of work to do :) ).

    At the moment I think we expect to get the Windows version of the extension in the asset store by the end of the year, and after that I imagine other platforms will be the next priority.

    Edit: Of course, it would be easier in some ways if the system was just a C# or JS script, but this is really the trade off of using native code. You can get certain performance and memory advantages (and we can also integrate with other 3D game engines in the future), but there is more work involved to support the different platforms.
     
    Last edited: Sep 8, 2013
  43. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Here's another quick update - we've been working on support for painting textures onto Cubiquity's smooth voxel terrain:



    It basically works the same as with the standard Unity terrain editor, in that you assign textures to slots, pick the one you want to paint the terrain with, and then just click and drag on the terrain to apply it. Unlike other voxel terrain systems there is no need to mess around choosing different top/side textures for triplanar texturing, you can simply paint any selected texture onto any part of the volume (whether it's horizontal ground or a vertical cliff face).

    Only two textures are shown in the above screenshot but I think the free version of Cubiquity will support up to four. I'll post again in the coming days to show this off.

    p.s. Yesterday we released another snapshot in our 'Assets and Asset Store' thread (textures are not in the snapshot but they are in the Git repository).
     
    Last edited: Sep 13, 2013
  44. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    We've been doing some more work on painting textures onto the voxel terrain. One advantage of our approach compared to other voxel terrain systems is that you can freely mix and blend between materials, in the same way as is possible with the standard Unity terrain. So we can provide different brushes with different falloffs, and these can be used when both sculpting and when painting.



    On the left you can see a hard edge brush has been used, which creates steep cliff faces when sculpting and sharp transitions between materials when painting. On the right a much softer brush is used, which creates rolling hills and smooth transitions between textures.

    I'll try and make a video soon to show this off more clearly.
     
  45. NarkLord

    NarkLord

    Joined:
    Sep 24, 2013
    Posts:
    13
    This voxel engine is looking really good. The demo is very smooth and feels solid, I'll be interested to see how much you can push the size limit of the worlds.

    I'm most interested in the cubic version, is it possible at the moment to have voxel sub objects in the world? eg: building a house with voxels on the terrain - having specific rules for the the way it can be built.
     
  46. NarkLord

    NarkLord

    Joined:
    Sep 24, 2013
    Posts:
    13
    I've been playing with this and the results are very promising.
    I like the way the engine is structured such that the base functionality to add and remove voxels is there.
    I was able to modify the voxel painting and adding so easily, I'm thinking of make a video when I have created a few tools to demonstrate.

    Something I really liked was that I could place 2 voxel terrains on top of each other - one for the terrain - one for buildings.
    This allows you to interact with them separately.
    Want to be able to destroy buildings but not the terrain? Easy, just add the click to destroy script to the buildings volume!

    I don't know if that functionality was planned but it's really awesome. It brings much flexibility, eg: you can hide the buildings and view terrain only on the fly. Hopefully it will allow other things, such as hiding some walls of a building to view inside, and maybe even having a different struct to describe the buildings volume.
     
  47. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Thanks, I'm glad you like it :)

    Yep, that would be cool. The example tool is very basic and just shows how to draw individual voxels, but it should indeed be easy to build on top of this. You could have differnt brush sizes, or some tool which lets you place larger blocks of voxels. I think the user interface is probably the hardest aspect of this, but do ask if you have any questions. Also, watch out for this issue as it will probably catch you at some point.

    Nope, it was completely accidental! We added the support for multiple volumes but at the moment you cannot apply transformations to them, so they just stack up at the same point in space. This will be fixed eventually, but I guess you can just leave them untransformed and treat them as 'layers' if you prefer. I wonder if the physics engine handles it ok?

    Also, be aware that the free version of the system will only support a limited number of volumes... maybe four or so.
     
  48. NarkLord

    NarkLord

    Joined:
    Sep 24, 2013
    Posts:
    13
    I tried to check out the issue but it says access denied.
    I'd like to know the issue however.

    I'll certainly be looking at the paid version if development continues, especially if large worlds with multiple volumes are possible, with layered volumes aswell.
     
  49. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Sorry, the issue tracker was set to private. I've set it to be public now.
     
  50. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Sorry there's still no video but we've been hard at work on the editor for the voxel terrain. It's nice to get the interface a bit more finalized before we make a video of it. Here's a picture of it in action:


    A few things have changed since our previous screenshots. Most notably there's now a bright blue marker which shows the current brush position and which also indicates the falloff. The inspector is also a bit more polished with an easy interface for selecting the brush and material to paint with. Overall the whole thing is a lot like Unity's built in terrain editor so it should be intuitive to use.

    The screenshot also features four different materials, with the inside of the cave using a different material to the outside. Both grass and sand have been painted onto the ground. Again, you can paint any material onto any surface without needing to mess about with 'top' or 'side' textures.

    We've got a bit more work to do and then hopefully we can get the new video out at the weekend.