Search Unity

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
    There is a converter to turn a .vdb into a set of .png images, so maybe someone in the AoS community would be intrested in writing a script to turn these into a .vxl file?

    Otherwise I can write the conversion script for you as it should only take a few hours. Maybe we can come to another arrangement ;-) But let's finish off our previous deal first (no hurry though).

    But do you really need a list of the voxels, or can you not just iterate over the voxels and fix them as you find them? I imagine that iterating over all the voxels should only take a few seconds, and maybe appending them to an array/list actually takes more time and memory?

    I think it's probably a bug in Cubiquity. The raycasting works by taking small steps along the ray and repeatedly checking whether it is inside the volume (which sounds inefficient, but the point is that it works without a collision mesh). If the steps are too big then you can be inside the volume before you realize you've hit it. The proper solution is to then do a binary search between the two last points but I didn't implement that yet.

    I logged an issue for it: https://bitbucket.org/volumesoffun/...ue/30/raycast-can-penetrate-too-far-into-mesh
     
  2. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    When you ask Cubiquity to return the coordinates of a voxel it returns the centers, not the actual surface you think that you clicked on.....0.5 below the surface is the exact dimension to the center of the voxel. The voxels are 1x1x1 so the centers will be 0.5,0.5,0.5

    When you click on the sides, or bottoms of the voxels does it still have have the same .05 offset? If so then what i am describing might be your reported problem.

    If not then sorry, I have a hard time reading English still.

    @David that sounds AWESOME! I will be in touch soon!
     
    Last edited: Feb 12, 2014
  3. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    @David cheers for that, it's something i'm correcting with a simple offset, but I think it may also be possibly be affecting another plugin (A* Path-finding Project) which generates navmeshes at run-time for me. I've not got a strong need for a resolution yet so no rush, as I'm done with my terrain generator scripts, so I'm just generating flat landscapes for any time I need to do stuff at runtime.

    @Voxi, your written English is good :) I'm using a VolumeTerrain, which means there are no visible voxles cubes like in the CubeVolumes to click on.

    I like how your game is looking! It's really nice to see what others are doing with the engine. You've inspired me to generate some terrains from my game and populate them and post some pictures in the next week or so. Nothing super special but pictures are always nice to look at ;)
     
  4. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    I'll be really interested to hear how the pathfinding stuff works out for you, because I think a lot of people will want to make use of that. Is it using the collision mesh or somehow hooking into the raw voxel data? The collision mesh should not suffer from the offset problem mention previously - it should exactly match the rendered mesh. In the future there will probably be the option of a lower resolution collision mesh as well which might be useful to you.

    Please do! It's also inspiring for us to see what people are doing with the engine, and it helps generate publicity for the project (important while we're not on the asset store).
     
  5. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    Among other things I am using the A* middleware as well.

    There is another product here called TeraVol. It is no where near as nice of voxel engine as cubiquity, but one thing it does have is A* buildt right into the terrain system somehow. I bought it as a novelty , and saw that the path finding REALLY works well. There is no NavMesh that I can see, it seems to make the path nodes dynamically when it generates the terrain, or the user alters the terrain. It even goes through the caves!

    The TeraVol voxel engine is extremely lacking for my needs though. No block mode, Really BAD documentation, really shaky generating. Poor quality hit detection with the player rig.

    Cubiquity is clearly the best choice. TeraVol is only a fun little toy. I don't recommend buying it for serious commercial use.

    If Cubiquity had this feature , it would be a major selling point for new developers. I bet an AI plugin could be sold, or offered as a separate package and be EXTREMELY successful.

    Thanks, :D

    EDIt:
    Ellandar , thank you so much! Looking forward to your shots.
     
    Last edited: Feb 13, 2014
  6. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    It is indeed possible to perform A* search directly on voxel data. Actually we have an implementation of this in PolyVox (the library Cubiquity uses internally) but we haven't exposed it Cubiquity yet.

    There are advantages to doing it this way. As you say, it should avoid the need for a collision mesh, and should be fairly robust for finding paths across volumes. But there are drawbacks too - it won't work between volumes and it will go straight through obstacles such as trees or buildings if these are not represented in the voxel data (mostly a problem for smooth terrain). I'm not sure how it will compare from a performance point of view.

    It's probably worth having both implementations available. I've logged an issue here: https://bitbucket.org/volumesoffun/...ue/31/support-basic-pathfinding-through-voxel
     
  7. someunityguy

    someunityguy

    Joined:
    Jun 28, 2011
    Posts:
    35
    The A* for the block volumes would be AWESOME david......................
     
  8. Ellandar

    Ellandar

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

    I'm probably not going to be very popular when I say this, but I'd rather not have Cubiquity provide A* pathfinding capability. I really enjoy that this product focuses on the voxel terrain generation alone. Every iteration it gets better at doing exactly that. Diluting it with other things like path-finding seems (to me at least) a negative influence on the progress of the plugin.

    However, I do think that providing the voxel data to allow other pathfinding plugins to use that as it's graph/grid would be an ideal solution! Probably a good 3rd party plugin option there: "Cubiquty graphing for A* Pathfinding Project" :)

    I took a deeper look into this, after you mentioned the collision mesh. I'm using the "RecastGraph" which generates a navmesh at runtime (also allows cutting and regeneration of new meshes at runtime): http://arongranberg.com/astar/docs/class_pathfinding_1_1_recast_graph.php. It turns out with a bit of tweaking of the settings, a higher resolution begins matching up with your terrain.

    I think what was happening is the Navmesh was just a lower resolution than your terrain, so when hills were present, sometimes the mesh would cut underground between points. This lead to annoying pathfinding problems where the unit would be standing in the right x,z co-ords, but not be close enough to the waypoint on y.

    There's a couple ways around this. Higher resolution pathfinding navmeshes, which take a while to generate (nothing a good loading screen can't hide!), or use the grid graph method which works fine with no modifications at all. I can see a third option and that is creating the graph based upon voxel information, and then using the rest of the pathfinding plugin to determine which nodes are un-walkable due to obstacles.
     
    Last edited: Feb 14, 2014
  9. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    @ David,
    You must have supernatural powers or something. Every time I have a voxel dream you seem to steal it and put it into your engine by ways of magic!
    I think in ancient dialect DavidWilliams directly translates to "Builder of dreams". My heart fluttered a little bit when you said you already had A* in PolyVox. My biggest concern is getting things to dynamically navigate the terrain. I am actually missing sleep thinking of ways I can place pathnodes or generate Navemesh dynamically when the players alter the cube volume.

    As far as the collision for my prefabricated mesh is concerned, I was just planning on adding and removing invisible-solid voxels inside the models volume. When the player hits the trigger to destroy the prefabricated mesh, it removes the invisible-solid voxels that are stored in the meshes local array variable. This should prevent "Minecraft floating tree blocks", I want trees to chop down like real trees 8).

    In other news i was playing with the Shaders and found out that Vertex displacement works out really well


    The video does not look like much, but it means that we can do enhanced earthquake effects, and shockwaves from blasts. I can now have a cool earthquake effect like in the classic game "Giants :Citizen Kubuto"!! None of this 1960's StarTrek "Oh we will just shake the camera" crap. We can have REAL LIFE earthquakes with waves!

    (There is no collision displacement so the effects must just be visual.)

    Also I did a spring camera test, along with a flat shader for the terrain :



    The video does not really do it justice! It is skipping frames to keep the video small, The game is running at full speed :D

    This is just some stuff blowing up:


    I will make some nice screenshots as soon as I have a nice map available to take pictures in. Everything I have right now is pretty bare without trees and houses.
     
  10. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Wow, it's really great to see the enthusiasm surrounding this project :)

    Regarding the pathfinding, I do think it is worthwhile to expose a basic A* implementation through Cubiquity. As with the raycasting, you can already do it directly through Unity but there may be scenarios when it is better to operate directly on the volume data. Also it doesn't need to affect the volume API as it would just be a standalone function which takes a volume and two end points as parameters.

    That said, the scope of such an implementation does need to be limited (basically to what we already have in PolyVox). It will literally just give you a list of voxels connecting two end points, and it may be slow (depends on path length). There no support for running it in the background, avoiding other meshes, or coping with the environment changing during pathfinding. So if you do have more advanced pathfinding needs then one of the existing Unity solutions are probably the best option. We should then include an example of how such integration can be performed.

    Yep, this is very interesting assuming the pathfinding plugin exposes some kind of API we can use. I vaguely recall hearing that RAIN allowed something like this, maybe A* pathfinding project as well.

    Edit: I should also say that the pathfinding is relatively low priority - i.e. not until after we get the first official release on the asset store.

    @voxi - Awesome stuff as always! Love the destructible trees and in-game objects. Looks like it's really coming together nicely :)

    I'm having a slow couple of weeks at the moment - partly because I'm busy at work and partly because I'm still rebuilding my dev machine after it failed. Should be back up to speed soon.
     
    Last edited: Feb 15, 2014
  11. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    @David - A* pathfinding code is all supplied so if it doesn't do what we want, i'm sure one of us avid fans can cobble something together :)

    Ditto on the slowdown here too. Work has skyrocketed so programming at home takes a hit. I've decided to do a little bit of stuff on the side to mess with a cubicVolume in cubiquity + http://www.gamedev.net/blog/33/entry-2249106-more-procedural-voxel-world-generation/ + http://forum.unity3d.com/threads/162158-Released-Aubergines-Noise (which is a C# implementation of http://libnoise.sourceforge.net/.

    First hurdle is creating the gradient function, as libnoise/Aubergines-noise doesn't have such a function. Luckily the author of the gamedev article has chimed in with some c++ code: http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=93 second last post, so hopefully i'll be able to make a suitable c# version and get some interesting generations happening!
     
  12. voxi

    voxi

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

    I made a quick little script for making bitmap buildings. My mod developers will be able to define their city's with "Style " files. Styles will control window , door, and walls dynamically so they can randomize their buildings to make unique game-play experiences every time.



    This is just one of many tools I have for VoxShot's editor. Thanks for looking 8)
     
  13. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    @voxi - Wow, that's really cool :) You might also be interested in the following article if you haven't seen it:
    It starts with some slightly complex maths/proofs, but I don't think the actual algorithm is too hard. You basically cut away anything which you can be sure is invisible from any of the three view directions. I don't think it can create things like windows though so your approach is more powerful for that.
     
  14. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    @voxi looking really good mate!

    I was just looking at your videos earlier, it's looking really good now.

    How are you building your shaders? I really haven't gotten into them yet, I've just finished the terrain generation stuff I was talking about earlier; just have to clean the code up a bit before releasing anything. You wouldn't be able to share a shader or two I could learn from? This latest work i'm doing is with the cubicVolumes so your shaders should work.
     
  15. Ellandar

    Ellandar

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

    I spent Sunday afternoon extending Aubergines Noise port of Libnoise (http://forum.unity3d.com/threads/162158-Released-Aubergines-Noise) with functionality that will allow me to implement Josh Tippetts awesome articles on terrain generation:
    http://www.gamedev.net/blog/33/entry-2249106-more-procedural-voxel-world-generation/
    http://www.gamedev.net/blog/33/entry-2227887-more-on-minecraft-type-world-gen/

    He has a few others, look around on gamedev.
    I needed to add Gradient functionality that setup a gradient as he listed in his article. I also needed to extend the existing Turbulence (I created another type actually) that allows the user to supply noise functions for each axis instead of having the turbulence function do it for you. Josh helped with some ideas for this via PM, as he also found libnoise a little limiting so he wrote his own library!

    The code used to generate the terrain almost matches Josh's functions in his scripts line for line:
    Semirare vs Normal stone from above link:
    Code (csharp):
    1.  
    2.     {name="SemiRareFBM", type="fractal", fractal_type="FBM", basis_type="GRADIENT", interp_type="QUINTIC", num_octaves=4, frequency=2},
    3.     {name="SemiRareFBMRemap", type="scaleoffset", source="SemiRareFBM", scale=0.5, offset=0.5},
    4.     {name="SemiRareSelect", type="select", main_source="SemiRareFBMRemap", low_source="Stone", high_source="SemiRare", threshold=SEMIRARE_DENSITY, falloff=0},
    Semirare vs Normal stone from my code:
    Code (csharp):
    1.        
    2.      // Semi-Rare ores
    3.         Perlin semiRarePerlin = new Perlin { OctaveCount = 4, Frequency = 2 };
    4.         ScaleBias semiRarePerlinRemap = new ScaleBias(semiRarePerlin, 0.5f, 0.5f);
    5.         Select semiRareSelect = new Select(semiRare, stone, semiRarePerlinRemap);
    6.         semiRareSelect.SetBounds(SemiRareDensity, 1000);
    I'm quite proud of the resultant code, and unless things change a fair bit, the noise implementation should match fairly closely for future articles too (mostly) :) This will allow people to follow along with his articles as much as possible.

    Ok, onto some screenshots, I have spent very little time finding good values and the underlining noise combinations are EXACTLY as they are on Josh's latest article (first one linked above). Next up i'll be creating biomes and such to have planes and hills etc.

    Two regular terrains below, no caves. Caves work well I just don't like them for screenshots. I can add them if anyone wants to see a screen of one. All of these maps are 128 x 128 x 50, and take about 7 seconds to build. I yield after every row has been created so you can see the maps grow as they are being built. I should get a video of it, it's quite neat :) It's faster without the yields.

    $GeneratedTerrain1.png $GeneratedTerrain2.png

    This one is a neat trick where I provided the ability to remove all stone (grey blocks) from the map. It allows you to see the rare (blue) and semi-rare(yellow) mineral deposits under the ground.
    $GeneratedTerrain3noground.png


    I do intend on releasing the code to do all this, and i'll submit the changes I made to the noise library to Aubergine, it'll be up to him if he wishes to include them in his package. I'll submit them here too. It's quite late here at the moment, so it'll probably happen tomorrow.

    cheers!

    Ell.
     
  16. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    @ David Willliams,

    I am going to have some fun with that! I think it might work nicely for a tree top tool. The kids who dont use Blender will like the character modeling aspect of this system too. Some people are really good at visualizing 2D when they draw. (I am the opposite, it is easier for me to “sculpt” in 3d. I cant sketch to save my life.)

    Your wonderful examples are what made my building tool possible David! Your un-finished package is better than a lot of “finished” packages on the unity store. thanks!

    @Ellandar ,

    You have some really amazing terrrain examples! I am really looking forward to seeing what you come up with.

    I have not had the time or patience to sit there and manually go over the terrrain generating example in cubiquity line-by-line to make it work with the cube mode yet. I really hope your generator saves me some time ,I don’t have much funding left for full time development.

    As far as generrating the noise I have a great utility for you to try :
    http://catlikecoding.com/unity/products/numberflow/

    We are not just stuck with Perlin noise. It has Simplex and a few others iirc. It is a neat node based editor, I was able to get it working in about half an hour for a basic noise function.

    He already has the terrain visualizer done for us. If you get to it before I do please post how you get it to work with Cubiquity.

    As soon as I get the building system to a functioning/useful state I plan on releasing the source for you guys. The voxShot editor will be free to everyone to use for their games as well :).

    I deleted the shaders in the video, but I can make some new ones in just a few minutes when i get home from treatment. I use MonoDev editor, EasyShader, SimpleShader and Shaderforge to help make things faster. ShaderForge is the neatest but has some odd licenceing, so I am going to avoid using the shaders with it in my game until I talk to a lawyer about ownership of the shaders it produces.

    The first thing I will try is a shader to map texture on Coal , rock, sand , or whatever. i will be really easy because you already have the vertex color set. We just need to find a way to disable the obnoxious default noise in Cubiquity and there are all kinds of possibility’s for mapping shaders to certain blocks.

    i am really really looking forward to seeing your generator code Ellander! Seeing neat veins of sand and stuff under the terrain really , really cheered me up today! thanks ! i am very excited to get home and get back to work! I am going to make the building scripts extra-cool for you guys 8) .

    EDIT: If you decide to buy ShaderForge here is a video explaining how to map per-vertex coloring.
    http://www.youtube.com/watch?v=2ZNJ_KytrE4

    You will need to make your own UV cords for the blocks if you wanted to texture them, you can do this by the Camera projection, or by the normal face direction nodes iirc. Cubiquity might do some sort of UV map, but I cant seem to discover it Via shaderforge nodes.

    If you get it to work before I do please share your findings :D, i should be home in a few hours, and I can give it a go.
     
    Last edited: Feb 17, 2014
  17. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    You guys are both coming up with some really cool stuff!

    @Ellandar - Can you tell what is the performance bottleneck for generating your terrains? I'm assuming it's the evaluation of the noise functions rather than writing of the data into Cubiquity? Keep in mind that you have the option of generating terrain 'offline' and saving the results into a Cubiquity voxel database. This should then load much faster for your users.

    @voxi - You can turn off the noise by editing the shader here:

    Code (csharp):
    1. //Add noise - we use model space to prevent noise scrolling if the volume moves
    2. float noise = positionBasedNoise(float4(IN.modelPos.xyz, 0.1));
    You can just set 'noise' to '0.0' instead. Obviously we should expose this through the user interface but I haven't done that yet.

    You will probably find that texturing the blocks is non-trivial. In theory you can indeed use vertex colors to choose which texture you want to sample but keep in mind that Cubiquity was not really designed for this (it is aiming for simple colored cubes). I'm not sure how well it will work but I'm very curious to see you results :)
     
  18. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    @voxi thanks for your kind words. That noise generator seems like it isn't appropriate as I need 3d noise.
    I'm in Australia so our times are way out of whack 9am here now. But I can easily give you some code to build a terrain from a 2d texture that the plugin outputs. Need to wait 8 hours till I get home though.

    @david. The noise and build is fairly quick, ill do some benchmarking in the next few days. Its more than likely something im doing as there is no optimization going on yet. I had it generating terrains with 3.1 million voxels in 7 seconds when not yielding every row, so I don't have any speed conceens yet.

    I hope to post the code tonight along with some more terrains and screenshots.

    Ell
     
  19. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    Wow! it is that easy? How neat!

    You have done way more than most people as far as nicely commenting your scripts! Everything is really easy to follow. I hope my comment does not sound like a complaint. i said "obnoxious" because a lack of words, my only alternative was to say "Noisy noise". Re-reading my post makes it sound like i am mad or something. I was just excited, and forgot to proofread before posting. The time and patience I was mentioning is from me just being new to this stuff. The scripts and examples are really great so far! I am a very happy person.

    The block texturing thing is a learning challenge. I was not expecting anything more than what we already have as far as colored blocks.

    @Ellandar

    Here you go! if you have some other requests let me know.
    http://voxi.t15.org/downloads/Buiding Template1/shaders.zip

    Going to give the texture thing a whirl tonight, If I have any luck I will upload it to you guys :)

    About NumerFlow I am quite sure it does both 2D and 3D noise. (Maybe i am thinking about the wrong 3D?).
     
  20. Ellandar

    Ellandar

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

    Ok, here it is. I've packaged all the required stuff up into a unitypackage.
    Usage instructions:
    Open new Unity Project.
    Import package into project
    Open Scene in the Scenes folder.
    Run Scene.
    Select the "TerrainDemo" script in the Hierarchy and begin playing with settings.

    Use the scene view to look at the terrains, as I've tried to keep this package small thus no camera controls are included.
    The intent is you can hopefully import this whole unity package into your project and it shouldn't clash with anything.

    I've set some default values that seem to generate a terrain that is interesting, the default terrain will generate and should look exactly like the first image I posted yesterday (you'll need to move the camera around to the correct side). I've also forced these same default values in the code to start with just in case you forget them and want to reset back to defaults (just click the cog-wheel in the inspector for the component and click "Reset" and all the initial settings will return).

    The key files are:
    CubiquityGenerator.cs - Used to render the noise using the CubicVolume.
    GUIButton.cs - Render the "Regenerate Terrain" button, so you can regenerate at runtime.
    NoiseDemo.cs - The beating heart of the operation. This is the file that builds the noise and then sends it to the generator to run.
    ExtendedTurbulence - A turbulence module for Aubergines Noise that allows the user to supply their own noise modules as XYZ noise sources.
    Gradient.cs - A module that implements a gradient best described by Josh Tippetts here: http://www.gamedev.net/blog/33/entry...ld-generation/
    SpawnCoroutine - A script I made to allow me to spawn coroutines out of static (and non-monobehaviour classes).


    I'm releasing the above scripts (NOT INCLUDING CUBIQUITY AND AUBERGINES NOISE, only the scripts described above) into the public domain to anyone that wants to use them for anything they wish, no attached conditions. I'll talk with Aubergine to see if he wants to include the extra modules in the noise function; if not, i'm happy for them to remain here for anyone that wants them.

    @voxi - I'll take a look at the Texture2D generation now. Will probably just add it to the CubiquityGenerator and re-release. Thanks for the shaders, I'll have a play with them shortly too :)

    I'm going to add an edit here later and make bitbucket source for this stuff. I'll more than likely tweak it constantly :)

    Release: View attachment $EllandarsTerrainBuilderv0.01.unitypackage
    GIThub: https://bitbucket.org/Ellandar/ellandarsterrainbuilder/

    Ell.
     
    Last edited: Feb 19, 2014
  21. Ellandar

    Ellandar

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

    I just did a quick profile (using Benchy as I don't have pro) and it seemed 50/50 between noise lookup and setting a voxel.
    If you have Unity pro you might have better luck getting decent profiling, I'll probably do a little more profiling later this week.

    Ell
     
  22. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Whilst working on the heightmap tonight, I kinda went off on a tangent.
    I got to thinking "If I use exactly the same noise generator and construct the terrains using the same sample points and identical loop setup, surely I could make a smooth terrain look the same as a cubic terrain".

    Apparently you can. (Apologies voxi, I will get to the heightmap, i promise!)
    I'll update the code to do this once I get the released version updated and then submitted to bitbucket.

    $Terrain2Smooth.png $Terrain2Cubic.png $Terrain1Smooth.png $Terrain1Cubic.png



    Ell
     
    Last edited: Feb 18, 2014
  23. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    And some caves too. I used a CaveSize value that was probably a tad big, but oh well, you get the idea.


    $Terrain3Smooth.png $Terrain3Cubic.png

    Ell
     
  24. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
  25. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    Ellandar,

    I have made a bitmap importer today, Thank you for concerting doing this for us, I will post the importer in a little while after I make a nice GUI and Shader for it.

    This is really great I have everything I need to let the OpenSpades community start using my editor! Now i just need to get to work for the VXL Exporter utility :D
     
    Last edited: Feb 18, 2014
  26. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    @voxi - I opened the following issue though as usual it's mostly a reminder to myself and may not happen soon: https://bitbucket.org/volumesoffun/...issue/32/add-support-for-a-single-diffuse-and

    It won't do exactly what you need (the same texture will be used for all voxels) but it will be a start. I really will try and prioritize these issues soon though so that people have some idea what we're working on next.

    @Ellandar - That is seriously cool! You're making my own procedural generation example look quite poor by comparison, but this is a good thing :)

    Unfortunately I couldn't test your package. I got a lot of these error on import:

    And then this error:

    Are you using Unity 4.3? I'm actually on 4.2 and I suspect this is the problem.

    Still, you're screenshots are really cool and it's a generous donation. But actually I think you might be able to improve them further in the case of the smooth terrain:

    I'm going to assume that in the cubic case you are evaluating the noise function and then taking a threshold to decide whether a voxel should be solid or empty. Then when you moved to the smooth version you are using the same threshold and setting the density to be '0' or '255'? Actually you can probably bypass this thresholding and just write the continuous noise values (within the 0-255 range). This should give you a smooth terrain. See MaterialSet.cs if this isn't clear. Of course, you may actually want your current style for artistic or gameplay reasons but I just though I'd point out the alternative.

    Also, it's really great that you will release your stuff as public domain, but do remember that this doesn't apply to Cubquity and you need to make this clear (include the Cubiquity license with your redistribution). It's an easy oversight but I'm obliged to point it out ;-)
     
  27. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    Thanks David!! You really are a nice developer!

    I think my project is near what I need for the Desura Alpha development requirements, I will be in touch soon :)

    I am pleased to announce that my Blender heightmap tool now exports directly to unity's Cubiquity engine 8).
    No more messy bitmaps to manage , you can view your changes while you are working. (it takes a few second to render and switch apps and refresh the terrain of course :p so the video was cut)

    Here is a video from Blender to Cubiquity.


    Shadows are baked onto the terrain's bitmap before exporting, so, if you do not have a moving sun , you can use un-lit vertex coloring if you would like to save processing power 8).
     
    Last edited: Feb 19, 2014
  28. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    @voxi cheers dude. your bitmap importer is looking good!

    @david: I really am loving this engine!
    First I have to apologize about the release, you are absolutely right, and same goes for Aubergines plugin as well. That was rather lame of me. I admit I've never released anything before as my background is system admin not programming so this was a little clumsy :). I'll update the package and put in the license and disclaimers etc.

    Second, yes the package was made in Unity 4.3. I think what i'll do is write a readme on how to build the scene from just by downloading the scripts and creating the gameobjects. It's not really complicated so it might be the best approach.

    In regards to the noise function, it's a little different. Initially that was my approach but what that ended up meaning was the noise function passed to the terrain generator would only be controlling a single material (and the other materials would be basically determined by height or some other factor I could think up). This approach is slightly different:

    The short version is that the noise sent to cubiquityGenerator is infact a numerical representation of what you see. I use noise to determine where constant numbers are placed in the map, and the cubuqity just says "What constant number is at 1,1,1...and so on).

    Basically a flat map, with 1 layer of grass, 1 layer of stone, and the the next layer contains 2 units of stone, 1 unit of gold and 1 unit of stone looks like this:
    0 = air
    1 = grass
    2= stone
    3 = gold

    0000
    0000
    1111
    2222
    2232

    So the noise sent to cubuqity looks like that, which is why the generator samples points and then just maps that point straight to a material.

    The long/detailed version is:

    1. create a series of constant generators (basically a noise function that returns a constant number) that represent all of your elements in the scene, grass, soil, stone, gold etc. Lines 66 - 71 in the NoiseDemo.cs:
    Code (csharp):
    1.         Const open = new Const { ConstantValue = 1f };
    2.         Const dirt = new Const { ConstantValue = 2f };
    etc
    2. Determine which constant is your "Main element" ie, if nothing else is in the location then it's this. In the example, that is stone(value 3f).
    This means that basically the map consists of the number 3f. If no noise pattern is applied, cuibquity would just be told to place stone at every location on the map.
    3. Create a noise function for each of the materials, make it look like you want and then use a select function to inject it into the stone based upon the noise. Line 84 shows me injecting semiRare (yellow in the cubic volume) into the stone.
    Code (csharp):
    1.         Select semiRareSelect = new Select(semiRare, stone, semiRarePerlinRemap);
    4. Repeat as many times as you have materials.

    5. Now we have everything that represents what happens underground, next we need to create a "ground level". And that is done exactly the same way, we just inject "Air, or Open" and use a gradient as the noise source instead of noise.. If we sent the result of line 104 in NoiseDemo to cubiquity we'd end up with a nicely populated underground and a perfectly flat terrain. (See image at end of post)
    Code (csharp):
    1. Select groundSelect = new Select(open, dirtStoneSelect, mainGradientRemap);
    6. All that's left is to 'noisy' up the ground layer, and that's just done by creating another perlin noise and then using the ExtendedTurbulence module I wrote to push the ground around in all directions. This is lines 111 to 115.
    Code (csharp):
    1.        // Create noise to displace the ground.
    2.         Perlin groundShape = new Perlin {OctaveCount = 4, Frequency = 2, Seed = GroundSeed};
    3.         ScalePoint groundZScale = new ScalePoint(groundShape) { ZScale = GroundZScale };
    4.         ExtendedTurbulence groundTurb = new ExtendedTurbulence(groundSelect);
    5.         groundTurb.ZDistortModule = groundZScale;
    6.         groundTurb.Power = 0.5f;
    Send this resultant noise to Cubiquity and all it needs to do is map the individual numbers to materials, or in cubicvolume's case, colors.

    Hoped this helped anyone reading. It isn't the first approach most people take, but to me it feels like I have the most control using this method, as it separates the generation of the scene away from the terrain generator. Ideally it would mean the code is very easily ported to other generators by just changing the final call function. In fact this is exactly what allowed me to quickly generate smooth terrain after initially just building with the cubic terrain in mind.

    Smooth/Cubic code to follow soon, along with a GIT repository to sign up to and register inevitable bugs with.

    Ground with no turbulence attached.
    $GroundNoTurb.png



    Edit: David, I just had a re-read of your comments and I get what you are saying now. You are talking about the cubic looking surface in the smoothterrain.
    You are right, i'm going with material setting of 255 each time I iterate through xyz. I'll have a think about how I can set the materials gradually between 0/255 at the ground to air border, as that will probably help out a lot.

    Thanks for bringing it to my attention, I was just messing with the smoothTerrain wondering "how do I make this nice and smooth" and your post sprung to mind :)
     
    Last edited: Feb 19, 2014
  29. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    The Github for this stuff is here:

    https://bitbucket.org/Ellandar/ellandarsterrainbuilder/
    It contains the code and a directory with the releases i've made.

    @ David, I've updated the cubiquity package to include your license file and have also edited my previous post's wording to ensure yours and aubergines packages are excluded from the public domain comments I made.

    Ell
     
  30. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    Really great stuff Ellander! This is a very interesting tool, I had a lot of fun with it.

    A quick question about uninstalling?

    How do I remove your company name from my Unity menu bar? I deleted the folder it installed, but the company name is branded on my toolbar still.
    Restarting does not seem to help. Do you have it put files in existing folders or something? If so where are all the files?
    I reverted to my backup copy, and the name is not there anymore. When I load my project it still is though :/

    Guess it is stupid of me to try beta software in my projects folder, I was pretty excited to see it run though. TIA
     
  31. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Hmm that sounds like it could be the name of the scene.
    Have you tried opening one of your scenes?

    What is the name that is showing up?
     
  32. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    Hi, I cant remember the name, maybe it is the engines name? (Does it matter really?) Sorry about that.



    I should be at my destination in a few hours from now. I will check it out from my drop-box there.
     
  33. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Not a problem.
    Basically the package contains:
    • my scripts
    • cubiquity
    • aubergines noise.
    • 1 scene.


    That's it. To build it I imported cubiquity (copy the git files into a project), imported the noise (same as cubiquity), then wrote the scripts and built the scene.

    The only thing I can think of is that you double clicked on the scene, and it wrote the scene name to the top of your window, and you are still in the scene somehow.
     
  34. NarkLord

    NarkLord

    Joined:
    Sep 24, 2013
    Posts:
    13
    Nice work Ellandar!

    Worked fine for me, I look forward to the smooth version.

    That bitmap converter will be super handy aswell.

    awesome work by everyone :)
     
  35. Ellandar

    Ellandar

    Joined:
    Jan 5, 2013
    Posts:
    207
    Thanks dude. If you pull from the bitbucket, the latest version has the smooth terrain and also the first tests of a second pass smooth to get rid of the terraces that building terrains like this produces.
    https://bitbucket.org/Ellandar/ellandarsterrainbuilder

    The two files that updated were: noisedemo.cs and CubiquityVolumeTerrainBuilder.cs if you update just those two you can generate scenes like the screenshots earlier. There's a new button for smoothing...it's in beta at the moment so don't expect Awesome(tm) yet :)
     
  36. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    What a great honor! your first post is to say Hi to us! And that everything is OK.

    Thanks for this :)

    I should be there soon.
     
  37. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    I am still not seeing how i can fix this. So i just basically delete the folder it installs right?
    I do this and i still have the option welded on my toolbar.




    Sometimes i drag and drop folders by mistake during run-time, i thought this might be the problem. So i made a whole new scene and tried this again and it uninstalls fine. Once i start adding my FBX animations it seems to break something.
    Are you using Mac or Windows?




    well, on another note.
    I think I am going to be trying NumberFlow + cubiquity integration tonight.

    NumberFlow has some really easy 3D noise tools ,and a nifty terrain template all set up for us to learn from :)

    I am a big fan of Voroni noise for my nature shaders. With NumberFlow there are a bunch of really great diagrams that we can start out with. There is an option to make your own noise plugins too!
     
    Last edited: Feb 20, 2014
  38. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    Ok, I found the problem!

    You need to restart Unity after deleting the folder to remove things from the tool bar.
     
    Last edited: Feb 20, 2014
  39. Ellandar

    Ellandar

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

    I've created a greyscale 2D Texture mapper. It will convert any texture to a terrain but it will only sample the red channel of the texture if you use a colored one.
    Creating a colored one is a little more difficult because you would need a gradient to map the colors (ie, white = 0 height, red = -1, blue = .5, etc) to heights. I can write one as that wouldn't be too difficult, but if there's no demand for one then I won't do it.

    To use, start with a new project, and import just the Assets folder of this zip:
    https://bitbucket.org/Ellandar/ellandarsterrainbuilder/get/c38dad123649.zip

    The new scene is RenderTextureDemo under the scene's folder. Click play, select the gameobject called "Script" and you can begin messing with values. I've set some defaults that make a very normal looking terrain.

    If you want to use the mapper yourself, just call:
    CubiquityGenerator.Generate with the required overloads (texture, map dimensions, true/false) true/false is just the incremental renderer

    some pikkies:
    $GreyscaleHeightmap.png $GreyscaleHeightmap2.png


    An example of the settings required to make the second image.
    $sampleGreyscaleSettings.png

    Loose value descriptions (it's a bit more complicated, but this is a good general guide):
    Higher Frequency creates more hills.
    Higher Octaves make higher hills.
    Higher Persistence stretches the hills
    Higher Lacunarity makes rougher terrain (lots more bumps, lower numbers really makes smooth undulating terrains).
    Seed is just a random generator.
    Height displacement pushes the entire ground upwards or downwards.
    Lower values of scale will lower the hills and raise the valleys.

    Have fun.

    Ell.
     
  40. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    @Ellandar,

    Thank you very Much! This is a great tool to learn from! I already have a converter and a perlin noise editor all worked out for this. (The terrain in my video was generated from this). There are never enough examples out there, everyone can add their own bit of magic to enhance their code. I am sure I will learn something from this!

    @ the new guys
    The Maze tutorial included in the Cubiquity is checking for the red value in the bitmap when it is determining the colors. If a user simply changes the “.r” to a “.greyscale” you can read the greyscale properly. Importing the bitmaps as 16bit, point,clamp, no mipmap, advanced read/write on. And you should be good to go! The rest is pretty straight forward.
     
  41. voxi

    voxi

    Joined:
    Dec 3, 2013
    Posts:
    60
    Here is a video of the tree placement script I am including with VoxShot's Free to use editor. It should show people a fast way to populate their terrains with trees, buildings, cars, whatever... :D

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

    It populates by elevation or by a splatter texture, There are 3 prop slots, each with its own controls.

    I am going to include a bunch of shaders too :
    Flat vertex color only
    Vertex shaded
    Vertex shaded + vertex lit
    Vertex color multiplied onto a texture.

    In other news I got a cease and desist order from Jagex about Ken Silverman’s software they have licensed . Apparently it is not a free to use for commercial purposes.
    “Using Voxlap as a
    test platform or as an advertisement to another commercial game is
    commercial exploitation and prohibited without a commercial license.”

    I guess that VoxShots editor will have to be a separate open source package to use the VXL import and export from Cubiquity. I am going to call it Voxxit again so it is not confused with my commercial title.

    I am emailing them back seeing if a free editor is ok for the 512x512x64 VXL Ace of Spades game beta format.

    The main reason I wanted the export is for OpenSpades not their development builds that are being distributed by Buildandshoot.com.
    (Build and Shoot does not own the rights to the software they distribute with their “Build and shoot launcher” . The version of Voxxed they are distributing was licenced to Jagex so be careful NOT to use it if you are making a commercial game. The Development builds of Ace of Spades does not belong to them either so dont use the in-game mapping things tools either..)

    They only used the VXL in the development builds, I have a feeling the Email might be a prank, so I am trying to contact them today to clear things up. Someone recently added my company’s email to a bunch of porn mailing lists, so this might be part of the same attack. (Some of the lists where pretty good, so I am not even mad about that part. :D )

    My game maps, and the in game VoxShot editor will only load and save in my own text format until I clear things up. You guys can use the maps for your games too if you would like. I still want that functionality to be available to everyone.
     
    Last edited: Feb 20, 2014
  42. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    There's so much cool stuff going on in this thread that I can hardly keep up! It's really great to see the stuff people are working on, and to see people sharing code and ideas. It gives a nice positive vibe to the community :)

    As for myself, I'm getting back up to speed on Cubiquity after a busy couple of weeks at work. I've just gone over the issue tracker and closed about half the issues which were fixed or no longer relevant. I've also created a version tag for version '1.0', and have applied this to the issues which I want to be resolved before we get on the Asset Store.

    The idea here is to be open about which issues we're actively working on. It's all subject to change but at least it gives some indication. You'll notice that Linux and MacOS support have made the list... there's been some progress here but it's not ready to show yet.

    @voxi - it really sucks about those legal hassles, but hopefully it means they're just nerveous about your game ;-)
     
  43. NarkLord

    NarkLord

    Joined:
    Sep 24, 2013
    Posts:
    13
    Is threre an example of importing voxels from magica Voxel? What format to use?
     
    Last edited: Feb 26, 2014
  44. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    There is a command-line tool called 'ConvertToVDB.exe' in the 'StreamingAssets/Cubiquity' folder. You can use this to convert Magica Voxel files (in the default format?) to Cubiquity voxel databases. I forget the exact syntax but if you run the program with no parameters it should print out the required usage. Obviously we should wrap this in a GUI within Unity but we haven't done that yet.

    I must admit I'm now a bit hazy as to how you get the .vdb into Cubiquity for Unity3D. You basically place the .vdb file in your streaming assets folder, and you can then create an instance of ColoredCubesVolumeData passing the .vdb path as a parameter. Then you can create a ColoredCubesVolume and set the 'data' attribute. Sorry this isn't well tested... we should make an example showing this importing of external data (but it would be easier with a GUI anyway).
     
  45. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    In other news, several people have requested callbacks to notify game code once the terrain mesh has been generated. I've just extended the Volume class with an 'isSyncronized' property, and also callbacks to indicate when the state of this property changes. There's an example of usage in MeshSyncHandler.cs:

    Code (csharp):
    1. void OnEnable()
    2. {
    3.     ...
    4.        
    5.     if(volme !=  null)
    6.     {
    7.         volume.OnMeshSyncComplete += PrintSyncCompleteMessage;
    8.         volume.OnMeshSyncLost += PrintSyncLostMessage;
    9.     }
    10.  
    11.     ...
    12. }
    13.  
    14. void PrintSyncCompleteMessage()
    15. {
    16.     Debug.Log ("Mesh syncronization complete");
    17. }
    18.    
    19. void PrintSyncLostMessage()
    20. {
    21.     Debug.Log ("Mesh syncronization lost");
    22. }
    Note that editing the volume data in real time will cause a stream of these event as syncronization is lost as a result of your changes and then regained as Cubiquity catches up. Therefore for the purpose of (e.g.) spawning your character when the terrain is loaded you might want to unsubscribe from the event after the first occurance.
     
  46. milliams

    milliams

    Joined:
    May 7, 2013
    Posts:
    5
    Hi all, Matt Williams here. I'm David's brother and co-developer at Volumes of Fun.

    I've been working over the last few weeks to get Cubiquity working across all the platforms so you can use it on Linux and OS X as well. I've written a post detailing what was done on our blog so do check that out here. In the meantime here's a screenshot of one of our sample programs running under Linux: View attachment 89067

    The Linux support seems to be working quite well on all the systems we've tested on and once we're happy with it we'll start work testing the OS X support too. You can try out the Linux support today from the Git repo and I'll post again once OS X support is ready for testing.

    Do test out the Linux support and let us know if it does or doesn't work.
     
  47. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Massive thanks to Matt for taking the initiative here. I'd previously said that Linux/MacOS was still a couple of months away, but he's brought it forward by doing the hard work for me.

    For those interested in testing the Linux export it should work exactly as you would expect - there are no extra steps required. We have been able to test it ourselves but of course we're still interested in your feedback.

    MacOS is a bit more of a challenge because we can't test it as easily. We'll do what we can, and then put out a build in the next week or two to get feedback from other users here.
     
  48. sinoth

    sinoth

    Joined:
    Jan 15, 2013
    Posts:
    30
    Is there a hard limit of four materials per terrain object? I'm having trouble finding info on this. If there is indeed a limit, do you have any suggestions on what we can do to have more than four materials?
     
  49. DavidWilliams

    DavidWilliams

    Joined:
    Apr 28, 2013
    Posts:
    522
    Yes, I'm afraid that four materials is currently the hard limit. In the future I expect it will raise to eight, but I don't currently plan to go past that. Have a read of the discussion starting here: http://forum.unity3d.com/threads/18...lyVox/page10?p=1505160&viewfull=1#post1505160
     
  50. sinoth

    sinoth

    Joined:
    Jan 15, 2013
    Posts:
    30
    I'm having a hard time conceding to a four material limit. Eight seems more reasonable. For example, my forest scene could use the following:
    • Grass
    • Leaves
    • Large stone (cliff face)
    • Small stone (river bed)
    • Dirt
    • Sand
    I could almost get by with four if we could also tint the terrain, so my grass and leaves could also be dead (tinted brown/yellow) and dirt/sand could share a texture. I'm not entirely sure how this would work, as Unity's built-in terrain doesn't allow this either. Vertex colors? Really not sure, as I'm not familiar with Cubiquity's render pipeline. I'll try to dive into it this weekend.

    Have you looked at the RTPv3 shader? (link) I wouldn't mind forking over the extra cash if it meant more layers and the additional quality RTP provides, but I'm not sure it will work with Cubiquity. This is what the PDF mentions with regards to voxel terrain:

    Does Cubiquity do anything with vertex colors currently? Also, by the sound of this we may be back to the four material limit (assuming you use the vertex color RGBA as four different textures.)

    Cubiquity is really shaping up to be a fantastic terrain system. I'm not as interested in the colored cube terrain... I doubt you will get many people forking over $200 for that. The smooth terrain is very compelling though and worth the price. I worry it won't be seen as professional enough with such a restricting texture limit, which makes it impractical for all but the most basic terrains.