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
    You don't need Visual Studio installed (though it won't hurt), just possibly the runtime libraires I linked to.

    Actually an easier test is to try one of our prebuilt demos, like this one: http://www.volumesoffun.com/downloads/Cubiquity/CubiquityUnity3DTest3.zip

    This helps determine whether it is an editor problem or a Cubiquity .dll problem.
     
  2. ScTar

    ScTar

    Joined:
    Oct 7, 2012
    Posts:
    14
    There was no terrain when I ran your demo, then I installed the VS10 redistribtable and in your demo and in unity the volumes started loading.

    I am able to create voxel terrains now however, I am not getting any of the volume creation options. Colored Cubes Volume has no drop down menus, and there is no dialogue like I saw in your youtube videos. This is what I get: $Capture.PNG
     
  3. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Great, I'm glad that fixed it, I'll try to update the .dll so that this isn't required.

    I'm afraid the system updates quite frequently so old videos get out of date. The video corresponding to the latest snapshot is this one: http://youtu.be/3kckUJG0KBA

    The dialogs are indeed gone because I wanted to get the user to a working terrain as soon as possible. The functionality is generally still available though (usually through scripting). What are you trying to achieve?
     
  4. ScTar

    ScTar

    Joined:
    Oct 7, 2012
    Posts:
    14
    I was looking for a way to set the size of the volume when creating it. I can see the benefit of speed, especially as a demo, but it is very unlikely I will ever use the default volume size in my projects. I will almost always want to change the size.

    Could volume size be added to the component? If you could do this, it would also be nice when resizing to have the option to fill new volume with ground at x height or something along those lines.
     
  5. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    In the last snapshot the easiest approach is to edit MainMenuEntries.cs and set the size to what you want to create.

    But I think the way it should work is like the standard Unity terrain - a single click in the menu gives you a working terrain of the default size, and then you can replace the terrain data with one of a different size if you prefer.

    I think the last version had already separated the Volume from the VolumeData, and the latest Git version has broken things down even more into multiple components (VolumeRenderer, VolumeCollider, etc).
     
  6. raveren

    raveren

    Joined:
    Aug 29, 2012
    Posts:
    14
    I'm also getting a DLLNotFoundException, but only in standalone builds. In the editor everything works fine but standalone players fail to find the DLL. I've manually checked and copied the DLL to make sure its in both the plugins directory and the root directory (next to the exe), and it still fails to find it. I'm on Windows 8.1. Any ideas about that? It's occurring in TerrainVolume.OnEnable, when it calls into CubiquityDLL.NewTerrainVolume (which calls cuNewTerrainVolume from the DLL). Quite frustrating because the DLL path the exception gives is the one directly to where the DLL actually is located.
     
  7. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Actually I'd make sure it's *not* in the plugins directory, because technically it's not a plugin (despite the name of this forum thread...) and this could confuse Unity. From ScTar's experience it seems the 'DLLNotFoundException' can also occur when the .dll is actually found but doesn't load for other reasons.

    If you don't copy it manually at all then it should happen automatically. The Cubiquity docs say this happens too late to be useful but I recall that I fixed that now. I *think* the process of making a standalone build should be fully transparent.

    Also which version of Cubiquity are you using (a snapshot or the Git version)?
     
  8. raveren

    raveren

    Joined:
    Aug 29, 2012
    Posts:
    14
    I'm just using the snapshot version, (4 i think?). This happens regardless of whether I manually try to copy the dll around.
     
  9. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
  10. raveren

    raveren

    Joined:
    Aug 29, 2012
    Posts:
    14
    Tank demo works, although I am using the TerrainVolume rather than colored cubes volume. I'll PM you with the build.
     
  11. ScTar

    ScTar

    Joined:
    Oct 7, 2012
    Posts:
    14
    I'm having a lot of fun playing around with cubiquity, but have a few questions.

    How do the weights work on the TerrainVolume?
    I have a script that creates a sphere, but to make it smooth I have to user blur, is there a quicker way of smoothing? How can I set the smoothness while setting voxels for a sphere?

    Is cubiquity able to load and unload blocks so that I can have a very large or "infinite" terrain, or is this on its way ?
     
  12. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Great, I'm glad your enjoying it :)

    This is a good question, and the use of material weights is an important concept which is unique to Cubiquity. At least, I have never seen another voxel engine which uses them. Because of this I decided to start writing some documentation rather than answering in the forum where the information may get lost.

    Therefore the MaterialSet documentation has been updated here: https://bitbucket.org/volumesoffun/...aster/Assets/Cubiquity/Scripts/MaterialSet.cs

    It actually quite a lot of documentation, so I might move some of it to a user manual in the future.

    One option is to base the voxel value on the distance to the center of the sphere. This is inherently a smoothly changing value and should give a good result. However, you will actually want to subtract the distance from some largish value, so that your values are high in the middle of the sphere and low at the edges, and you'll also want to scale/shift the values to get the right range.

    Actually I recently started writing an example to generate plannets. It doesn't do what I describe yet but keep an eye on it here: https://bitbucket.org/volumesoffun/...ets/Cubiquity/Examples/SolarSystem/?at=master

    Also be aware that the API has evolved since the last snapshot, but the principles still apply.

    Cubiquity stores all its voxels in a database on disk. This means it is difficult to do truly infinite terrain as the space requirements would get very large. However, it does load blocks on demand and page them back to disk if too much memory is being used, so you should be able to have a reasonable size terrain. I haven't tried pushing it very hard yet, as I've been more concerned with getting all the pieces in place.
     
    Last edited: Jan 19, 2014
  13. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Just a quick note that I've added a 'MaterialSetDebug' shader to Git. This just draws the four material weights as red, green, blue, and yellow, so you can more easily see which material is being applied and how multiple materials are being blended together. Should be useful in particular to anyone who is playing with procedural terrain generation.

    You can find it in Git, and I think is should also work with the last snapshot though I didn't test it: https://bitbucket.org/volumesoffun/...s/Cubiquity/Resources/MaterialSetDebug.shader
     
    Last edited: Jan 19, 2014
  14. DavidWilliams

    DavidWilliams

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

    Sorry it's been quiet with the updates recently, but now we have some more stuff to show :) The images below show a voxel model of the Earth, complete with satellite data from NASA's 'Blue Marble' project. The main novelty here is that the texture is not applied using the traditional 'triplanar texturing' which most voxel engines use, but is instead read from a cubemap. In other words we've been overhauling the material system to make it a lot more flexible and powerful.


    Of course, it's really made of voxels so you can destroy it, perhaps simulating the impact of meteorites or space weapons. There are multiple layers of material to provide rock, lava, and a white hot core. These are done by triplanar texturing, which can be used in conjunction with the cubemap mentioned previously.




    Anyway, I hope this shows that Cubiquity is more than just another terrain engine. Voxels are really powerful so you just need a good imagination to come up with interesting uses :)
     
  15. someunityguy

    someunityguy

    Joined:
    Jun 28, 2011
    Posts:
    35
    So i am presuming the CreateProceduralColoredCubesVolumeWizard
    has gone from the latest snapshot because you changed the way you generate the cubic volumes ?
    curious if its going to pop back up ?
     
  16. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Actually I just didn't think the generated terrain was very attractive, and I hadn't got around to making it nicer. Similar functionality is now demonstrated by the 'Maze' example, in that it shows how to create and populate a colored cubes volume from code. The API may have changed from when you last looked at it but the principles remain the same.

    I think the wizards will return in some form. At the moment I'm trying to push as much functionality as possible out of the 'core' of Cubiquity and into examples. This keeps things tidier and emphasizes that there are more things you can do. But then I haven't quite decided where the wizards would fit into this... are they just examples or part of the core? I'm giving it some thought.
     
  17. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Another quick update - Cubiquity volumes now behave a lot more like standard Unity game objects. For example, it is now possible to build a hierarchy of volumes by setting the parents and children as appropriate. The screenshot below shows a voxel Moon orbiting a voxel Earth, which in turn is orbiting a mesh representing the Sun. This is all animated, and it is possible to click on the volumes to edit them even while they are moving.


    Additionally, the code structure is now closer to what you would expect from a Unity extension. You can add a 'Volume' component to a GameObject and then specify the asset containing the actual volume data. You can then add a VolumeRenderer and/or VolumeCollider, and the expected properties (such as material are present). Altogether I think it's starting to feel quite natural :)

    We'll try an make another video and release a new snapshot soon.
     
  18. Ellandar

    Ellandar

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

    First i'd like to thank you for such a good voxel tool, I'm very happy with it so far!

    This issue is in relation to the TerrainVolume (not cubic) and from code pulled from the bitBucket repository last night (probably happened before too, but i've only just implemented this).

    I'm programmatically creating a terrain using:

    Code (csharp):
    1.         // Create a region, then spawn a terrain.
    2.         mapRegion = new Region(0,0,0,MapWidth,MapHeight,MapDepth);
    3.         currentTerrainGameObject = CubiquityVolumeTerrainBuilder.GenerateVolume(mapRegion);
    4.  
    5.         // Set the map's layer to 8 (which is ground)
    6.         currentTerrainGameObject.transform.ChangeLayersRecursively(8);
    The CubuiqutyVolumeTerrainBuilder is just a class that builds a terrain using whatever your latest method is, it protects me from having to update all my code every time a release is made that changes the creation methods. In this case it's a direct copy of your menu code for building a volumeterrain.

    The issue I have is with my mousecontrol script. If a unit is selected, and I click on the screen somewhere, it will send a raycast from the camera, through the mouse position and then return whatever it hits first.

    If the hit object is on layer 8 (my ground layer) it will send a "Move To" message to my selected unit.
    If it's not on layer 8 then it will send an "Interact With" message to my selected unit.

    My issue is when clicking on the ground i'm getting a "InteractWith" message.
    If I select the terrain in the inspector, the Layer is 8.
    If I then select the Layer 8 and click on the "Apply to all children" then do my test again, the "Move To" is being sent correctly.

    My assumption here is there's something going wrong with the layer setting in the VolumeTerrain?

    if it helps, my "ChangeLayersRecursively" code is:
    Code (csharp):
    1.     /// <summary>
    2.     /// Changes the layer of a gameobject and all of it's children given the layer number.
    3.     /// from: http://answers.unity3d.com/questions/168084/change-layer-of-child.html
    4.     /// </summary>
    5.     /// <param name="trans"></param>
    6.     /// <param name="layerNumber"></param>
    7.     public static void ChangeLayersRecursively(this Transform trans, int layerNumber)
    8.     {
    9.         trans.gameObject.layer = layerNumber;
    10.         foreach (Transform child in trans)
    11.         {
    12.             child.ChangeLayersRecursively(layerNumber);
    13.         }
    14.     }

    Any ideas?

    Rob
     
  19. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Hi Rob,

    I haven't worked with layers yet so there is most likely a bug in Cubiquty here. How are you peforming the raycasting? Are you using Physics.Raycast() or Cubiquity.Picking.PickSurface()?

    The former will be using the MeshCollider, and the most likely problem is that although you are setting the voxel game object to be on a particular layer, it actually has a number of hidden child objects which are possibly not be set correctly. I may need to make sure that any child objects are synced to match the layer of their parent game object. This is something which should be done inside Cubiquity.

    If you are using Cubiquity.Picking.PickSurface() then I need to fix that to take a layerMask parameter like the Physics.Raycast() does.

    I don't have the code in front of me so this is just off the top of my head. I'll have a closer look tonight.
     
  20. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Hi Rob,

    Just another note about your layer-setting code. It looks like should handle setting even the hidden children of game object, but I wonder if it is being called before the hidden objects are even created? This could explain the issue.

    If it helps you can unhide all the children by commenting out the following line in Cubiquity:

    Code (csharp):
    1. newGameObject.hideFlags = HideFlags.HideInHierarchy;
    Then you might see what is going on. Anyway, I shall try to take a proper look later.
     
  21. Ellandar

    Ellandar

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

    That's spot on, it was the child object that didn't get the layer set.

    I am using a physics raycast for that, so it could be the problem there, i haven't finished re-factoring the code to support the voxel engine fully yet. I've created a work around that applies the layers at a later time.

    --- EDIT ---- Please Ignore past this point, I figured i'd start some debugging before sending you off on a potential wild goose chase, and it seems to be returning a value that is correct (need to do some trials to make 100% sure).


    I do use Cubiquity.Picking.PickSurface() to ensure my camera movement doesn't go below the surface, and I have noticed that it's returning negative numbers when the main VoxelTerrain Gameobject location is set to 0,0,0. Now I can see the child objects I can see the reason why. I think there may be an issue with the return from PickSurface there, as in my scene it should never return below y = 0 at the moment (all my land is at around 15).

    this is the code I'm using:

    Code (csharp):
    1.         PickSurfaceResult resultantSurface;
    2.         if(Picking.PickSurface(currentTerrain,target.position + new Vector3(0,50,0),-Vector3.up,100,out resultantSurface))
    3.         {
    4.             terrainHeight = resultantSurface.worldSpacePos.y;
    5.         }
    My current target is a gameobject that is supposed to always sit on the ground (invisible) that the camera uses as a focal point. At the moment it's sitting under the ground and I haven't yet tried to work out why (it's on the todo). The camera can zoom away from the target, so I just zoom out a little and pretend it didn't happen :)

    Rob
     
    Last edited: Jan 27, 2014
  22. bigboy4006

    bigboy4006

    Joined:
    Apr 13, 2012
    Posts:
    65
    Out of curiousity, does this work with models made in Qubicle Constructor? And will it work with the file format it saves to, or do I need to export the model in another file format (such as an OBJ file)? :confused:
     
  23. Ellandar

    Ellandar

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

    Have a look back through this thread (around page 4-5 I think, been a while) there was a bit of talk about the Qubicle Constructor.
    I don't believe there's any out of the box support, but one of the forum members got a custom export happening, perhaps they could be talked into sharing it or releasing it as an asset.

    David has mentioned that importers are something that will be looked at, I expect after the core functionality of the voxel engine has been honed down enough so it's stable enough not to change too much. ie, I doubt David wants to have to worry about too many dependencies at this stage of the project due to the re-factoring and rewriting that's going on.

    Rob
     
  24. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    In addition to what Ellandar said, it's worth noting that we can import from Magica Voxel, and this application can in turn import from Quibicle Constructor. So in principle there is a pipeline for getting data into Cubiquity but obviously it would be nice if it were more direct.

    Also note that Cubiquity is intended for representing worlds - if you just want characters or vehicles then you should probably import then as meshes using the Quibicle Unite tool.
     
  25. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    I've just added a fix for this to Git. Please update when you get a chance and let me know if it works for you.
     
  26. bigboy4006

    bigboy4006

    Joined:
    Apr 13, 2012
    Posts:
    65
    I'll have to take a look back through those pages Ellandar. I'm always looking for ways to import models from one piece of software to another.
     
  27. bigboy4006

    bigboy4006

    Joined:
    Apr 13, 2012
    Posts:
    65
    I've already got MagicaVoxel saved to a DVD-ROM disc David - I'll have to look into it. As for Qubicle Construct itself, Voxel Pirate has a YouTube channel devoted to Qubicl Construct tutorials. He's an add-on for Blender to import Qubicle Construct models into Blender (and I know Blender files can be directly into Unity). The only catch is that you to have the Stonehearth license in order to use the Blender add-on.

    And that's why I was asking about Qubicle Construct - it's easier to have that direct pipeline in the first place.

    And as for Cubiquity, I didn't realize that it was meant for that. As for the Qubicle Construct, I'll take a look into my various options - buying Qubicle Unite, or one of the the licenses for Qubicle Construct. I'd like to get at least the Home license for Q.C. so I can do more work on those models in Blender - then import those models into Unity via Blender. I've already been giving some thought to it already.
     
  28. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    It's important to consider whether you need real voxels or just the appearance of voxels, and also what you want to do with your voxel objects. Cubiquity works with real voxels which can be added or removed at runtime, but it's quite hard to perform animations. On the other hand, Quibcle Unite exports as regular meshes (I believe?) which can then be animated but you won't be able to modify them at runtime.

    This is why Cubiquity is great for representing your environment and modifying it in-game, while regular meshes which just look like voxels might be good for characters or vehicles. The two technologies can be used together very effectively, and Quibicle can be used as both a world design tool and as a character design tool (I think... I've never actually used it).

    Keep researching and I think you'll come up with more interesting ideas. Remember that you can download Cubiquity for free just to see what it can do.
     
  29. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    @bigboy4006

    Qubicle construct does not export to blender format. It instead exports to OBJ file format. You need to do about 5 minutes worth of tweaking to get it looking right. Then you may need to do some poly reduction. i am the one working on the blender importer but it is far from done.

    There is also another product that imports directly into unity called Qubicle Unite. You get cracks in the meshes though. It does not decimate the meshes properly. You will need to get a DAE importer for blender to fix it manually.

    It also does not weld the vertical. You are left with blobs of floating triangles that you need to manually re-weld in blender.

    If you want to save some time and money you can just use the remesh modifier in blender.

    I tried to participate in the Qubicle Unite discussion to help them to not render cracks in the meshes and my messages where intercepted and not published by one of the moderators. It seems they know the problems and do not want the consumers to know about it. It is still an OK product, and it still has some uses, but do not expect a finished "AAA" product. most of the time you will be better off to manually do it in blender.

    I will have the blender importer ready soon. It does proper poly reduction and the UV mapping and texture baking.

    PS if you are buying QC for the VXL exporter you are in for a few rude surprises too. I helped them sell a bunch of copies to the Ace of Spades community. I did not find out until later that the product I was endorsing did not even remotely do what was promised for that community. The maps it exports have some major problems with them, and the smaller matrix for the players gun and player model so not save a "pivot" so they are useless.

    If you want a VXL map utility try Voxlap game engine by Ken Silverman. It will compile a map editor for you called VOXED. It is the best voxel editor on the market, and it is FREE!!

    I am going to be releasing a Voxel terrain tool for the Cubiquity community soon. (used in the famous "JoJoe-Stinky" maps!).
    There will also be some animation tools for some very nice voxel modes too.
    I have a light mapper, and a few other utilitys that I am sure the community will like.

    I am also looking into a VXL exporter from Cubiquity-Untiy. There is a programmer in the build and shoot community that has written some papers on VXL file format. I am just waiting to get some $$$ so i can pay him to try it. If he gets it to work, i will release my map editor free for the Cubiquity community.
     
  30. Ellandar

    Ellandar

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

    Just tested and it worked perfectly. I still had to setup a coroutene to give it a bit of time to create the child GameObjects before setting the new layer, but all else worked fine.

    Perhaps an option down the track could be to add a callback on terrain completion to allow us to hook in post-processing on terrains?

    Thanks very much David.

    Just in case anyone else was interested in an example on how to generate new terrain, this is what i'm doing:

    Core Game code (somewhere in your game/app)
    Code (csharp):
    1.     // Build the map
    2.     mapRegion = new Region(0,0,0,MapWidth,MapHeight,MapDepth);
    3.     currentTerrainGameObject = CubiquityVolumeTerrainBuilder.GenerateVolume(mapRegion);
    4.    
    5.     // Wait 1 second and then Set the map's layer to 8 (which is ground)
    6.     StartCoroutine(WaitAndChangeLayer(currentTerrainGameObject, 8));
    7.  
    My Coroutine is:
    Code (csharp):
    1.     IEnumerator WaitAndChangeLayer(GameObject terrainGameObject, int LayerToSet)
    2.     {
    3.         yield return new WaitForSeconds(1);
    4.         terrainGameObject.layer = LayerToSet;
    5.     }

    my CubiquityVolumeTerrainBuilder has recently been changed to match what David has in his Create Terrain Volume menu entry:

    Code (csharp):
    1.    public static GameObject GenerateVolume(Region inRegion)
    2.     {
    3.  
    4.         TerrainVolumeData data = TerrainVolumeData.CreateEmptyVolumeData(inRegion, VolumeData.Paths.StreamingAssets, VolumeData.GeneratePathToVoxelDatabase());
    5.  
    6.         // Create some ground in the terrain so it shows up in the editor.
    7.         // Soil as a base (mat 1) and then a couple of layers of grass (mat 2).
    8.         TerrainVolumeGenerator.GenerateFloor(data, 6, (uint)1, 8, (uint)2);
    9.  
    10.         // Now create the terrain game object from the data.
    11.         GameObject terrain = TerrainVolume.CreateGameObject(data);
    12.  
    13.         // Set up our material 
    14.         Material material = new Material(Shader.Find("TriplanarTexturing"));
    15.         terrain.GetComponent<TerrainVolumeRenderer>().material = material;
    16.  
    17.         // Set up the default textures
    18.         Texture2D rockTexture = Resources.Load("Textures/Rock") as Texture2D;
    19.         Texture2D soilTexture = Resources.Load("Textures/Soil") as Texture2D;
    20.         Texture2D grassTexture = Resources.Load("Textures/Grass") as Texture2D;
    21.  
    22.         // It's possible the textures won't actually be found, as they are just examples and the
    23.         // user might have decided not to include them when importing Cubiquity. This doesn't
    24.         // matter and just means the uer will have to set up their own textures.
    25.         if (rockTexture != null  soilTexture != null  grassTexture != null)
    26.         {
    27.             material.SetTexture("_Tex0", rockTexture);
    28.             material.SetTextureScale("_Tex0", new Vector2(0.125f, 0.125f));
    29.             material.SetTexture("_Tex1", soilTexture);
    30.             material.SetTextureScale("_Tex1", new Vector2(0.125f, 0.125f));
    31.             material.SetTexture("_Tex2", grassTexture);
    32.             material.SetTextureScale("_Tex2", new Vector2(0.125f, 0.125f));
    33.         }
    34.  
    35.         return terrain;
    36.     }
    37.  
    Rob
     
    Last edited: Jan 30, 2014
  31. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    In theory Cubiquity can suffer from this as well, though I haven't had many issues in practice. Its a common voxel problem. If people do find it to be an issue there there are some solutions I can try.

    I guess you've seen the writing code here: https://web.archive.org/web/20130527190047/http://silverspaceship.com/aosmap/aos_file_format.html

    Are you planning to write the exporter inside Unity using C#, or as a seperate application which converts between the two formats? There's C sample code at the bottom of that link, so maybe it's not too hard to convert it to C# to implement the first option.

    Right, sorry, that's the bit I was supposed to fix! The children now inherit the layer from their parent whenever the parent's layer changes, but I forgot to set the initial layer correctly. I'll have another look later.

    Yep, this makes sense, and something like it is proposed here: https://bitbucket.org/volumesoffun/...ue/25/provide-a-way-to-check-if-mesh-is-up-to
     
  32. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    @Ellandar - The layer problem should now be fixed (see this commit). You can now set the layer as soon as you create the voxel game object and the octree nodes will inherit it when they later get created. They also stay synchronized with any further layer changes. Let me know if it works for you.
     
  33. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    @David - Perfect!
    Works without a delay coroutene now. I changed the layer a few times at runtime as some tests and all the child gameobjects applied the layer with the parent.

    This is perfect, thanks David. Really liking what you are doing with this plugin too. Cheers.


    Rob
     
  34. DeatchSmyle

    DeatchSmyle

    Joined:
    Dec 11, 2012
    Posts:
    4
    I tried to rewrite the script ClickToCarveTerrainVolume so that I also can add Voxels. But I don´t know how to do that.
     
  35. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Did you get the 'normal' version of the ClickToCarveTerrainVolume script to work, i.e. so that you can click to delete parts of the volume? You need to add the script to a TerrainVolume and then click on the volume in play mode.

    The way it works is that when you click it iterates over the nearby voxels and sets them to an empty material:

    Code (csharp):
    1. MaterialSet emptyMaterialSet = new MaterialSet();
    2.  
    3. //Later on, inside a loop...
    4.  
    5. terrainVolume.data.SetVoxel(x, y, z, emptyMaterialSet);
    But you can make it so that the variable called 'emptyMaterialSet' actally has something in it:

    Code (csharp):
    1. MaterialSet emptyMaterialSet = new MaterialSet();
    2. emptyMaterialSet.weights[0] = 255; // Sets material '0' to be fully 'on'.
    3.  
    4. //Later on, inside a loop...
    5.  
    6. terrainVolume.data.SetVoxel(x, y, z, emptyMaterialSet);
    Of course, you may also want to rename 'emptyMaterialSet' as it's not really empty now. Now when you click it will create a sphere of material '0', whatever that is set to.

    Material sets are a little complex, so do read the documentation (and sorry it's not better) and ask here if you have questions.
     
  36. DeatchSmyle

    DeatchSmyle

    Joined:
    Dec 11, 2012
    Posts:
    4
    Now everything works but now to my next question. If the number of textures limited?
     
  37. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Yes, currently four textures are supported for the TerrainVolume, and most likely eight will be supported in the future. This might not sound like a lot, but this is because the system is mainly designed for modelling terrains rather than constructing buildings out of voxels (although to some extent it can be used for this purpose).
     
  38. ScTar

    ScTar

    Joined:
    Oct 7, 2012
    Posts:
    14
    I think restricting cubiquity solely to terrain is not necessary. I feel like destructible buildings would serve as much if not more of a purpose than destructible terrain in many games, Battlefield and Everquest Next are two examples. Even in your cubed volume tank demo you use cubiquity to create buildings, because it's fun to blow them up. While trying to make buildings like walls out of cubiquity, the first noticeable problem was texture blending of tile textures. I don't want concrete blending with a brick wall. This is especially a problem when you are dealing with non-solid voxels. I think one solution, though it may not be the optimal solution, is to have the option to turn texture blending by averaging weights off. Then, one value of what is now material.weight would be used as density, and the other 3 (or 7) values leftover could be used to hold any value the user wants: texture index, durability (like Hit Points for each voxel), or shader properties. It seems like a relatively easy fix, and would create a huge amount of flexibility for cubiquity.

    I'm currently working on generating a smooth line so that I can make walls and buildings. Then I plan on making a script for walking around these buildings, selecting voxels, and adjusting their density to create different architectural features, like a curved wall or an arch.
     
  39. Long Fall Games

    Long Fall Games

    Joined:
    Dec 30, 2013
    Posts:
    10
    this this 1000 times this
    Specifically excited for the smooth terrain i will definatley be using this in my game cast.
     
  40. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Actually I should have clarified that my comment was only with regards to the TerrainVolume. In contrast, the ColoredCubesVolume can (and should!) be used to build absolutely anything you like. It's a blank canvas for you to build you world with.

    None-the-less your points do still stand with regard to the Terrainvolume. If you want to disable blending then you can probably do this by modifying the TriplanarTexturing material. For example, you could look at the weights which come into the shader, find the biggest component, and set that to 1.0 while setting the other components to 0.0. Perhaps not optimal but it should give you an idea how it can look. You could also decide that only a subset of the materials should be blended, or that some materials should override others if they are present.

    Several people have asked about doing construction in the terrain volume so I do want to make an example for it in the future. Then I'll have more idea about how far the existing system can be pushed.

    A system specifically designed for structures other than terrain would probably handle the materials differently (as you describe), but I think it would also want to generate the geometry differently. Something like Dual Contouring is more appropriate than Marching Cubes as it is better at creating sharp corners. I would indeed like to see this in Cubiquity but the existing terrain and colored cubes volume need to be refined first.
     
  41. ScTar

    ScTar

    Joined:
    Oct 7, 2012
    Posts:
    14
    But David, I'm greedy. I want to be able, for example, to have the individual material.weights represent a texture index, a decal texture index (like bullet holes, rust, blood), Hit Points, and density. I have been trying to figure out how to possibly do some hacky things with shaders, I could have many more textures with the current system of weights by basing a texture index on one of the weights, but clearly this limits my ability to have one texture at every density value. Would it be difficult to implement an option like what I propose with marching cubes? Although, I'm sure in the future dual contouring will better suit my needs.
     
  42. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    @ScTar - There's really several related issues at hand here. First of all there's the issue of storing a single density value and associated material index (which is what some other voxel engines do) vs storing a set of material weights (which is what Cubiquity does). The first approach does indeed allow a larger number of textures, for example if you store the material ID as a byte then you have 255 textures to choose from.

    It brings it's own problems though, as this large number of textures is typically stored in a texture atlas (at least pre-DX10) and linear filtering does not work well in this case. Also blending and level-of-detail are more difficult, and are often missing altogether in other engines.

    Therefore Cubiquity accepts a reduced number of textures in exchange for higher-quality texturing. This is good for terrain but probably not go good for making buildings, etc. I can conceptually imagine a middle ground but it would need some more R&D to see how that works out.

    Ok, you got me thinking enough to open an issue: https://bitbucket.org/volumesoffun/...ssue/28/simplified-interface-to-terrainvolume

    Being able to store user-specified data (hit points, etc) is really a separate problem. In some cases you may simply be able to store this in a separate array, in which case it doesn't impact Cubiquity or other users. A regular C# array can hold millions of such values, and we will probably introduce a BigArray class in the future which would page such user data to disk.

    Sometimes you might want your user specified data in the shader, and in this case it would be better if it was really stored with the voxel data so that Cubiquity could retrieve it and attach it to your vertices. This would be an extra byte or two which would be added to all voxels and could be re-purposed for whatever the user wants. Actually the ColoredCubesVolume already has this, but that's because I just happened to have some spare bits left over.

    I think it is quite possible that some of the changes you describe will happen, or that a third volume type will be introduced which does things differently. So I do appreciate the feedback and ideas. But this isn't the priority at the moment, as we really need to focus on polishing what we have and getting on the asset store, as well as supporting other platform like MacOS/Linux. Then we can try some of these more adventurous ideas.
     
  43. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    Hi David,

    Try using vertex colors rather than using texture to color things. (If I read the post correctly you are UV mapping and coloring the faces with textures?)

    I got a copy of ShaderForge recently they have a really easy vertex shader you can try. It will save a lot of overhead as far as rendering is concerned.

    Well what you are seeing is cracks in the polygones from them not being welded properly. The cracks are ... well.... cracks. To make your mesh not have cracks in them you need to weld or share the verticles, otherwise there will be visible gaps at rendertime.

    The reason Qubicle is having problems has nothing to do with Voxel's, it has to do with meshes with cracks in them. This is why things exported from qubicle are not 3d-printable. The models are just a pile of floating triangles.

    Export an OBJ from qubicle , import to blender, remove doubles (this will weld the verts). and import to Unity, you will notice there are NO cracks. Now try the same thing with Qubicle Unite on the exact same matrix. You will see right through it at some points.

    This is beginner modeling stuff. I am surprised Mindesk cant do this properly.

    I never noticed any problems like this with Cubiquity, i will look closer with a white skycolor next time I run it. You did a nice job David. :)
     
    Last edited: Feb 4, 2014
  44. ScTar

    ScTar

    Joined:
    Oct 7, 2012
    Posts:
    14
    I appreciate the reply. I was going to ask you what your priorities for other platforms were but didn't want to overwhelm you with questions, you have magic legos to work on. I don't have much experience working outside of Unity, though I want to, and would like to help out if there is anything I could do to speed things up, like compiling on my mac, or just shutting up and waiting patiently while I play with demos. :)
     
  45. cmdrsabre

    cmdrsabre

    Joined:
    Feb 6, 2014
    Posts:
    1
    I like to hear, that MacOS Support ist a higher priority, because I would love to try out Cubiquity, but without a MacOS Version I can just read your code ;)
    Is there any chance of getting an answer on WHEN we can expect a MacOS version?
     
  46. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Right, sorry for the slow reply, I was having a busy week and then my main dev machine failed! Fortunately I had just recorded and uploaded the latest progress video to YouTube, and I'm currently in the process of rebuilding the dev machine so we can hopefully put out the snapshot this weekend.

    @ScTar - I also added an issue regarding the extra per-voxel data but I suspect it will be a while before I look at it. It's mostly just to remind me. I'll address your MacOS question further down...

    Cubiquity does not suffer from double vertices (two vertices will only share the same position if they have a different color), so I guess this is part of the reason why the rendering is higher quality that Qubicle. But it can suffer from another issue which is T-junctions in the mesh. These can be fixed, but it results in a higher triangle count so I'll wait until it becomes a problem.

    Actually vertex colors are already used for the ColoredCubesVolume, whereas textures are applied to the TerrainVolume. In the future I'd also like to add the option of normal maps for the ColoredCubeVolume to recreate the kind of effect we had in Voxeliens :) But in general I think the user should be able to provide their own material/shaders if they wish.

    Right, the elusive Mac version :) Unfortunately we don't have a set date. In terms of priorities, I can say it will probably happen after the free version lands on the asset store but before the paid version lands on the assets store. I really hope we can get the free version on the asset store in the next couple of months, so after that MacOS should be the priority.

    I think I should go over the issue list on BitBucket, clear out the completed tasks, and assign some priorities and milestones. Then maybe it becomes a bit clearer when these things might happen.
     
  47. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    Thought I would share a sunset scene from my upcoming game VoxShot:


    $voxshot1.png

    Getting close to a tech demo release. Cubiquity is making this all possible :)

    Is there a fast way to list all of the voxels that are a certain color in the volume?
    Lets say I need to find all the White, solid ones. From what little I understand, I am assuming I need to make a loop and systematically check every voxel's RGBA value to make a list (fill an array).

    Have you made a faster way of doing this? Can I do some magic function to return an array containing all of the white, solid voxels? (I say magic because I am in awe of Cubiquity's might).

    allTheWhiteVoxelsArray[*] = Some.magic.function.to.find.single.color.and.return.list (255,255,255,255);

    Thanks in advance :D.
     
    Last edited: Feb 7, 2014
  48. DavidWilliams

    DavidWilliams

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

    I'm pleased to say we've just released another progress update and snapshot of Cubiquity for Unity3D :)

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

    You can download the snapshot below:
    Head over to the 'Assets and Asset Store' thread or see our blog post for more details.

    Seriously cool stuff! It's really great to see what people are doing with Cubiquity so I do want to encourage others to post screenshots if they have something to show :)

    Unfortunately there is no built in functionality for this. What is the overall goal that you are trying to achieve here? Perhaps there is a better way to address it.
     
  49. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    What a wonderful demo!

    Melting planets with an alien death ray just got on my TO-Do list, if I ever do a space game ! Great work David!

    David about importing and exporting VLX maps, I am not sure how this will be done. I know with my current ability I can read off the matrix array into a text file with a loop. I have no ideas how he will change it into a VLX file though. I am just a Script kiddie when it comes to C#, Python, or JavaScript.

    Thanks for all the updates David! I have something nice for you, it should be done in a few days from now 8).

    EDIT:

    Bye the way i need to list all the White voxels in a volume as a workaround for my blender exporter. It makes some of the voxels pure white, or pure black because of my crappy way of doing palettes. (copying and pasting from other scripts 8) )

    It is just a time consuming task, and later it might be handy knowledge if I wanted to do some sort of global color replace with my in game editor.
     
    Last edited: Feb 10, 2014
  50. Ellandar

    Ellandar

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

    I have a problem using Picking.PickSurface where it's returning a value that seems to be .5 units below the surface.

    The code i'm using is:
    Code (csharp):
    1.  // Find the world
    2.         TerrainVolume currentTerrain = FindObjectOfType<TerrainVolume>();
    3.         if (currentTerrain == null) return;
    4.  
    5.         // Pick a location and then find the terrain in the world
    6.         float x = RandomProvider.Next(5, 95);
    7.         float z = RandomProvider.Next(5, 95);
    8.  
    9.         // work out what height the world is at this point.
    10.         PickSurfaceResult foundSurfaceResult;
    11.         Picking.PickSurface(currentTerrain, new Vector3(x, 50, z), -Vector3.up, 100, out foundSurfaceResult);
    12.         float y = foundSurfaceResult.worldSpacePos.y;
    13.  
    14.         // create the item and child it under the container.
    15.         GameObject newGameObject = (GameObject)Instantiate(SceneryList[itemToSpawn], new Vector3(x, y, z), Quaternion.identity);
    The result is the item spawns but is slightly below the ground. I've clipped the scene camera into the ground so we can see above and below it, and selected the object so you can see that the root is at the base, so the code above is supposed to put that transform point on the surface.
    $SpawnedObjectWithRootUnderground.png

    It's quite possible i'm doing something wrong here. The Maximo character standing next to the object is there due to physics apply gravity, I didn't place him on the surface with code, i just drop him from a height :)

    The diamond on the right of the screen is my in game camera target, it also gets placed below ground too, as i'm using the same code to place that as well.

    Edit: My last checkout of cubiquity was 11 days ago, so I'll grab another copy and give it a shot. Apologies I usually do that first but had forgotten this time.
    Edit 2: Just updated and problem persists. Kudos on backwards compatibility of update though, latest build dropped in and worked! :)

    Rob.
     
    Last edited: Feb 11, 2014