Search Unity

[WIP] Voxel Meshing

Discussion in 'Works In Progress - Archive' started by KiwyVoxel, Jan 14, 2015.

  1. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Hello everyone,
    I am glad to present to you my work : An exemple of procedural meshing based on voxel. It include the Dual Contouring, Marching Cubes and "Minecraft like" (Boxel) algorithms. Also an implementation of constructive solid geometry that allow easy construction, modification and destruction of meshes.


    Try it
    Dual Contouring
    DC.png
    Marching Cube
    MC.PNG
    Boxel
    Boxel.PNG
    Content
    • C# and Unity 5.0.1f1.
    • Dual Contouring algorithm. One rather faithful and quick technique, with sharps edges, used in Voxel Farm (and everquest next).
    • Marching Cubes algorithm. SIGGRAPHE 1987, base of multiples algorithms (including DC).
    • Boxel algorithm. Simple meshing technique well known because of Minecraft (helpfull for learning).
    • Multithreaded mesh creation.
    • Isosurfaces : Constructive Solide Geometry, heightmap, simplexe noise, sphere, cube, plane. Densities functions (f(x) = d, if d > 0 out of the mesh, d < 0 in the mesh).
    • Basic gameplay to create surfaces. Union, difference and intersection for constructive solide geometry.
    • Boundless World.
    • Chunk manager and game manager. Based on Finite State Machine for code lisibility. Dynamic chunk managment.
    • Chunk pooling. Avoid garbadge collection.
    • Basic character controler.

    Triplanar Shader (XZ / +Y / - Y axis)​
    Try it
    TriplanarShaders.png
    Shaders Content
    • 18 Surface shaders based on vertex position and surface's normal (Triplanar).
    • Based on local or world space position.
    • Allow three sets of textures on +Y -Y and XZ axis.
    • Diffuse lighting.
    • Specular Lighting.
    • Normal Maps.
    • Emission Maps.
    • Parallax Maps.
    • Opacity Maps for a better texture blending.

    Coming next
    • Ambient occlusion.
    • Better normal calculation (currently gradient method on DC meshing).
    DevBlog

    Feedback

    Any feedback or critics will help me greatly. I want this project to be as clear as possible for learning purposes. And i want to know what you would like to see in that kind of projet :
    • Other kind of voxel data structure ? (octree ?)
    • Another meshing algorithm ? (EMC ?)
    • More features for learning purposes ?
    • In editor UI ?


    If you have any question about this project or voxel technology don't hesitate to ask on this thread or contact me. I intend to make some tutorials in french i think there are better english guides than me. Once finished, I will make available this project on the store, the price is not fixed yet, but i would like it to be accessible for most people. I hope you enjoy what you see, and it motivates you to jump in the voxel wagon. :)
     
    Last edited: Sep 29, 2015
    EliasMasche likes this.
  2. Plexus1

    Plexus1

    Joined:
    Mar 9, 2014
    Posts:
    26
    This has a lot of potential! I want to make my own Dual Contouring implementation in Unity as I prefer it a lot to marching cubes as it can produce sharp features where marching cubes cannot, but I do not know where to start. I have searched Google for tutorials but I have found none in C# or Java. How do you get your implementation in Unity/Could you share any resources that would help me implement Dual Contouring into Unity?
     
  3. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    You should start with some of the SIGGRAPH papers. I think you should avoid Java as this is an expensive alogrithm and memory can be key. If your are juste starting, first i recommend to implement the Marching cubes algorithm, to understand how it is working. There is many exemple, and DC is juste an improved MC.

    One link that helped me a lot, but there are many interesting blog like Voxel Farm or ofps :
    http://www.sandboxie.com/misc/isosurf/isosurfaces.html

    I hope this post is helpfull, give me some feedback on your project.
     
  4. Plexus1

    Plexus1

    Joined:
    Mar 9, 2014
    Posts:
    26
    Thanks for the quick reply! I didnt realises sandboxie had an atticle on isosurfaces, looks very informative, im going to give it a read. I have implemented Marching Cubes into Unity before but I could never understand dual contouring. I will update you on any progress that I make.

    Also I think you should incorporate an octree based LOD into your project
     
  5. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Last edited: Jan 23, 2015
  6. SirStompsalot

    SirStompsalot

    Joined:
    Sep 28, 2013
    Posts:
    112
    Like the idea of using clipmaps here.

    Watching this project fondly. :)
     
  7. Ghosts_Riley

    Ghosts_Riley

    Joined:
    Dec 7, 2013
    Posts:
    82
    When trying the demo you provided I noticed the following things.

    1. I had to refresh the webpage to try a different algorithm

    2. When jumping the character controller behaves perfectly fine, but let's say you fall off a 100 block structure it will only take you ms-1second to hit the ground. I currently have the same problem with my character controller script. :(

    Overall this is wonderful! Keep up the good work!
     
  8. DJ_Design

    DJ_Design

    Joined:
    Mar 14, 2013
    Posts:
    124
    Amazing! Where did you learn all this if i may ask?
     
  9. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Hello, thank you all for your support. And first Update !
    • Added dynamic chunks managment, tick off "load all chunk.." to try it (Work in progress). Recycle form the chunk pool, display or desable inactive chunks. Especially useful if you are looking for large voxel world.
    • Added "B" hotkey to go back to the world setting screen as advise by Ghosts_Riley.
    • Added a bounding box debuging feature, hit "H" to highlight on/off. You can see isosurfaces boundries and where the scripts are working.
    • Better average fps.

    Try this here or in the first post : Voxel World - Update 23/01/15


    There is a lot of SIGGRAPH paper on procedural meshing and some very good blog on the subject (see link on my last post). If you have more specific questions i will be glad to answer as best as i can.

    I use a simple Physics.gravity for verticale velocity (and inverse for jump). I am not sure how Unity gravity work but you may be looking for a velocity acceleration (as your body take speed while fooling) rather than how i am doing it.
     
    Last edited: Jun 9, 2015
  10. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Update 13/02/15.

    Triplanar Shader, Normal and Parallax Maps - Update 13/02/15

    Today work in progress on my shader :
    • Triplanar shader (in this exemple XZ / +Y / - Y)
    • Texture blending.
    • Normal maps.
    • Parallax maps.
    The textures are not the best, and the shader is not optimized yet, but we can see some good results. Tell me what you think, and what you woud like to see.

    Good week end :)
     
    Last edited: Feb 25, 2015
  11. Makakaveugle

    Makakaveugle

    Joined:
    Mar 24, 2015
    Posts:
    1
    Yop !
    Very amazing work.
    I agree that some of the SIGGRAPH paper are really helpfull on the subject.
     
  12. Minja

    Minja

    Joined:
    Dec 5, 2014
    Posts:
    3
    Very nice work! Does your implemenation support sharp features? I'd love to see an implementation with a working octree - maybe even free for anyone to play with the code? Keep up the nice work!
     
  13. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Thank you for your support !

    - Dual Contouring support sharp features. But it create only one vertex by voxel, so the precision of the mesh depend on the space between two voxels.
    - Octree are very interesting for this kind of data structures, but it may complicated my code so it is not my priority for the moment. Also as said before clipmaps could be better than octree, but i am not sur it is doable in Unity.
    - I am spending a lot of time on that project so i would like to get some return on investment. But if you have any question or need somme help on the subject i can help you as best as my knowledge :)

    I know i didnt update this post since quite some time, but i don't like showing work not yet up to some quality.
    I will shortly show the news updates regarding multiple materials meshes, better normal calculation for shader and meshing from heightmap.
     
  14. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Hello everyone !

    The next update is finaly here :)

    Voxel World - Update 09/05/15

    Content :
    - Unity 5.0 upgrade.
    - Heightmap isosurface.
    - Multiple materials, use 1 2 and 3 to switch between them and create new meshes.
    - New normals for Shader (gradient method)
    - New Chunk Manager. The "Load all chunk" option will now load chunks from the player start position to the edge of the World in a spirale kind of way.
    - And lots and lots of debugging...

    Known buggs (non exhaustive) :
    - Very big drop frames at chunk creation (due to updating my voxels array). It is the main reason of the delay of this update. I know where it is coming from but i did not manage to completely resolve it yet. However i manage to soften the blow enough so it can be playable. Thus it may brings others buggs on texture and meshing.
    - Normal calculation. I am using the gradient methode of calculation for the shader normals. But as the meshing is not as precise as the densities functions, it creates texture stretching. I am looking at diverses others techniques as weighted normals.
    - The parallax effect of my shader doesnt work properly on procedural mesh according to your view direction.

    I hope you enjoy those normals, i think it looks realy nice with parallax :)
     
  15. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Last edited: Jun 2, 2015
  16. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Hello everyone on this beautiful summer !

    Today i would like to start with a little story. This project is my first project on Unity and in C#. For a long time i hesitate to learn and implement multithreading in it. So i spent an enormous amount of time comming with all sort of extravagant ideas to make my chunk manager work faster and faster with coroutines. I learn a lot, but i never reach what i was looking for.
    And then i found this ebook :
    http://www.albahari.com/threading/

    And i say to myself, what a wonderful day. Now let me present to you my project, with multithreading :
    Multithreaded voxel world creation

    And to show you the change of speed, a 200 x 36 x 200 world creation based on a heightmap (if you looked at previous build, you can see the difference) :


    No, not everything is perfect but i am realy pleased with this result.

    For those who are looking to do the same, let me explain how i did it.
    • I based my implementation on a consumer/producer queue (you can find an exemple in the book), with a number of worker thread equals to my cpu count -1 (for the main thread).
    • I keep an array of my meshingScripts objects, so each of them has its own memory allocation.
    • And finaly i replace every Unity function (Mathf, vector3, quaternion, etc...) that my meshing scripts was using, so they could be threaded.
    And voilà ! (with a lot of debugging).

    I have some issue :
    - I use the singleton pattern based on the Unity wiki singleton : http://wiki.unity3d.com/index.php?title=Singleton. But Unity dont like field initialization outside of awake and start function. So some time when i quit the game it raise lots of erors, and i dont know how to avoid it.
    - Marching Cubes was the fastest of the three algorithms (it is a lot of array look up). Now it is the slowest, and i dont know why or how to fix it yet.

    My next goal would be to extend my chunk manager to allow boundless world.

    I hope you enjoy what you see, and as always if you have any bug report, questions on this project or need help for your own, i am oppen to discussion. :)
     
    Last edited: Jul 10, 2015
    mliukka likes this.
  17. macdude2

    macdude2

    Joined:
    Sep 22, 2010
    Posts:
    686
    How did you implement the marching cubes approximation? Is there a paper/code for that as well?
     
  18. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    The basic Marching cubes approximation is very simple. Its the middle point between two corners , ie : 0.5.

    If you are looking toward more advance marching cubes based algorythme like the Extend MC (EMC), you need to intersect the edge more precisly. You do so by iteratively checking the density value of points on the crossed edge (you choose the middle point, between one of the corners and the last point you checked), until you get an acceptable density value (be careful with float to avoid checking for ever).

    For Dual Contouring it is a bit more complicated as you take into account mass point, normal directions, and quadratic error function minimization. I cant realy explain it properly and in details here. But, i can show you a good learning site, well explained and with code in C :
    http://www.sandboxie.com/misc/isosurf/isosurfaces.html

    You also can look at the siggraph papers, which are the most complete sources of informations.
     
    Last edited: Jul 16, 2015
  19. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Hello,
    In today's update the last implementation of my chunk manager.
    It's content :
    • Load and unload chunks from the chunk pool.
    • Launch chunks mesh creation if need to be.
    • Faster user's mesh modification.
    • Boundless world.
    • Meshing priority as follow : user input, chunk in view, and chunk in loading range.

    You can see the result here, first part for the DC algorithms, second a look at behind the scene and third Boxel the quickest algorithm, :


    And try it here :

    Chunk Managment

    Coming next I will work on my shader. I am also thinking about starting a more precise dev-blog to share my experiences and hopefully help who wants to learn about voxels.

    I hope you enjoy what you see. As always if you have bug reports, questions, or any other discussion related to that kind of project dont hesitate to ask.
     
  20. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Hohoho folks ! Welcome to Buster Friendly's show and his Friendly Friends !

    Today i have some exciting and totally unpublished information for you !
    We have sent our expert reporters to inquire about the latest updates on Voxelab and his shaders.
    And there is what they found :

    Shaders Content
    • 18 Surface shaders based on vertex position and surface's normal (Triplanar).
    • Based on local or world space position.
    • Allow three sets of textures on +Y -Y and XZ axis.
    • Diffuse lighting.
    • Specular Lighting.
    • Normal Maps.
    • Emission Maps.
    • Parallax Maps.
    • Opacity Maps for a better texture blending.
    Try it

    Oh my oh my ! What a news !

    A special thanks to Nobiax aka Yughues for his amazing and free textures (on cgshare, deviantart, Opengameart and unity store).

    To finish on a more serious note.
    I would like to imagine what our dear P. K. Dick would have to say after this :
    "Do voxels dream of electronic cubes ?"

    That's all folks ! Next on Buster Friendly and his Friendly Friends, the latest version of voxelab with those new shaders.
     
    Last edited: Sep 8, 2015
    mliukka likes this.
  21. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,476
    Hi, very good.

    I want to add triangle or other shape of 'block' other than cubic shape. and it should be integrated with cubic based world.

    How can it be?
     
  22. Vanamerax

    Vanamerax

    Joined:
    Jan 12, 2012
    Posts:
    938
    Those shaders are looking very good! How did you handle the normal and tangent calculation? Is this using surface shaders or custom vert/frag shaders? I am trying to figure out making bumpmapping triplanar shaders myself, but I am having trouble generating the correct normals etc.
     
  23. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Hello,

    It depends on what exacly you are trying to do.
    You can have sharp features like cubes or complexe shapes with Dual Contouring. To see the best results with this method you should look at Voxel Farm (or Everquest Next). If you tried my implementation there is two things to take into account :
    1. The more voxels you have, the sharper your shape will be (smothing = number of voxels/Unity unity).
    2. My script is ,not based on the latest methode of Dual Contouring, that's why you can see discontinuity on some edge.

    Now if you want a different resultat you can use multiple meshing algorithm on different spaces. You just have to find a solution to delimit wich voxels will be used with what meshing method.

    Those are written like Unity surface shaders. I tried with vertex lit shaders but i didnt had good enough results. And as they are dedicated to shade landscape i rather use less expensive shaders.

    As for the normal's calculation it depends on what type of shaders you try to make. For common shaders you can calculate your normal / tangent before sending it to your shader, with unity mesh recalculatenormals or doing it yourself with a cross product.

    For triplanar shaders it changes a bit if you use world's normals or object's normals. When i am meshing voxels with the Dual Contouring technic i have normals calculated by the gradient method, so i use them. Then you need to translate it into world/object space at the begening of your shader (in vert()).

    If you need more precise guide, try here for bumpy surface and here for triplanar texturing.

    I am glad you like my work, i hope my answers are helping you.
     
  24. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    A quick note, just to let you know that i am still working on this project.
    It has been slowed down a bit because of the guide i am writing and also about what is happening in my country.

    But i am working toward improving multiple points in my project. I would like to use octree and LoD and I am making some more research on clipmap.

    See you next time.
     
    Last edited: Nov 18, 2015
  25. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    341
    Really nice!!! This could be a good replacement for Ultimate Terrain. For now, uTerrain performance is the best among other voxel competitors. The only bad about it is no longer developed (similar cases for most Voxel Systems in Unity). If you beat uTerrain low memory footprint, fast performance, Biome system implemented, multi-threads LOD details system, fixed Floating Point error, and mobile support. Count me in, I don't mind to pay more than $200, for it :) Bookmarked!
     
  26. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Thank a lot for your support.

    Voxels are a very interesting and wide topic and it can be hard to make it all work. There is few projects that manage to get really good results, like Voxel Farm, Automontage Engine or Voxel Quest.

    Working with Unity imply some restrictions so i dont know if we can do as good as those projects. But I am going to try.

    I hope you will enjoy my next updates and dont hesitate to ask if you have any questions.
     
    ikemen_blueD likes this.
  27. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Hello fellow friends of voxels!

    As you may all know, projects based on voxels take a lot of time and work. And I think that this project has arrived at a point where it can be usefull to others.
    So to be sure that this project is a viable solution (as I have, like you, to eat and pay a rent :)), I took the decision to release my work on Unity's asset store, for PC, Mac and Linux platforms.

    And Voxelab is now available, on the forum or directly on the store :

    Complete Edition, with all my work, multi-threaded procedural meshing in real time, with the three main algorithms, chunk managment, triplanar shaders and more!

    Meshing Scripts, with only the procedural meshing scripts based on voxels.

    Triplanar Shaders, to easily texture any meshes or large terrains and avoid stretching without the need to use voxels or UV mapping.

    I know how expensive assets can be for small projects, so I tryed to split my work to be available to most. And I think the content value report is better than other products on the store. And even if you dont have money to spend there is a free guide on voxelab.fr.
    But dont hesitate to give me feedbacks. Do you have questions? Contact me at contact@voxelab.fr.
     
    Lohrion likes this.
  28. Lohrion

    Lohrion

    Joined:
    Aug 16, 2013
    Posts:
    107
  29. kizu7su

    kizu7su

    Joined:
    May 6, 2016
    Posts:
    5
    Bought the complete edition, going to spend all weekend tinkering with it.

    As for the feedback in the original post, a big YES to the three below gets my vote - so much to learn, and so nice to have one place to go to learn, and not have to spend a couple weeks getting a tutorial to even run in Unity to start playing with it:
    • Other kind of voxel data structure ? (octree ?)
    • Another meshing algorithm ? (EMC ?)
    • More features for learning purposes ?
    Thank you very much KiwyVoxel! May all of the people you'll eventually reach leave monuments to you within their code and games!
     
  30. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Thank you very much !

    I was at your place once, so I understand the struggle and I am very glad to be of help.
    There is so much to learn and to do with voxels, I think the best way is to dive in it.

    Dont hesitate to ask questions and share your experiences. Thank you for your feedback.
     
  31. ludos

    ludos

    Joined:
    Nov 14, 2011
    Posts:
    56
    in a short test i have replaced your Vec3D with the unity builtin Vector3. this gave me an enormous boost in performance.
    it may not work for other ppl, as i have disabled generating colliders and i am running 5.4 beta.

    i used refactoring to modify the X,Y,Z by x,y,z values and afterwards refactored the Vec3D to Vector3 and lastly commenting the generated Vector3 class. So i could replace the function within 5 minutes. (also better use Vector3.sqrMagnitude then Vector3.magnitude when replacing Vec3D.length().
     
  32. ludos

    ludos

    Joined:
    Nov 14, 2011
    Posts:
    56
    also change the function CalculateDensity of Cube to:
    Code (csharp):
    1.  
    2. public override float CalculateDensity(float x,float y,float z) {
    3. Vector3 p = new Vector3(x,y,z);
    4.  
    5. if(IsRotated){
    6. p=Quaternion.Inverse(rotation)*(p-center);
    7. }else{
    8. p-=center;
    9. }
    10.  
    11. p=Vector3.Scale(p,p)-Vector3.one*radius*radius;
    12. return Mathf.Max(Mathf.Max(p.x,p.y),p.z);
    13. }
    14.  
    edit:
    this does not have such a large impact in speed.
     
    Last edited: Jun 26, 2016
  33. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    341
    You can even go further with inline tricks. I did it for my custom Noise library, and even 30% performance boost, replace Inverse, Scale, Max function with inline statements, since this Calculate-Density function would be called so many times ;)
     
  34. ludos

    ludos

    Joined:
    Nov 14, 2011
    Posts:
    56
    How do you do inlining in c#. All documentation on this topic i found dont give useable answers.
     
  35. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Thanks, it's an option I wanted to try for a long time but I didnt had the time to do it.
    I had multiple errors with Unity's built-in functions and multi-threading, hence I get rid off as many function as I could. Then letter I read somewhere that Vector3 functions was ok to use...

    As for the inline I did consider it (and many more optimization options), but the goal of Voxelab is also to be an easier access for learning purposes. Most projects dont need three meshing method...
    And inline funcitons can be very usefull but is quiete combersome to read.

    If I have the time I will update Voxelab and its good that the information is available here.
     
  36. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
  37. juuuuun

    juuuuun

    Joined:
    Feb 17, 2014
    Posts:
    23
    Just bought your asset and looks promising so far.

    I wanted to check whether it is possible using your asset to make some kind of realtime voxel sculpting using the script provided in this asset.

    I tested this with the demo file provided in the asset by just continuously call MakeSelectedIso() while mouse button is pressed, but it was a bit too slow to use it for sculpting. I would like to see the mesh continuously built and rendered while I'm pressing mouse button like 3DCoat ideally. Any idea how I could use this asset to use for realtime sculpting or is it just not possible with this asset?

    Thank you!
     
  38. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Thanks for you support !

    It is absolutly possible to make realtime voxel sculpting, in fact this is - with other specifications - what Voxelab is.

    To clarify I will make an assumption on what you are looking for : You are looking for an extruding tool.

    First lets see what is the issue.

    Voxelab use by default a groupe of basics densities functions : noise, sphere, cube and plane. When you are calling MakeSelectedIso() you ask to mesh one or more of these shapes.
    Now to assemble those shapes the Constructive Solide Geometry principle is used. Which means that when you add a shape you also need the density of every other shapes in the same bounding box (I don't use a data structure).
    Then you need to use that density float to calculate the new mesh, and all that is quiet an heavy load on the CPU.
    So when you call MakeSelectedIso() while the mouse button is down, probably each frame, you are overloading your CPU, hence the frame drop.

    But there are multiple options, it depends on your project :

    - Put more time between two mesh calculation. By default Voxelab will register every shapes you add, but also call the calculations asap. So you can modify the coroutines sleep times (yield return new WaitForSeconds for example).
    - Use simplier densities functions. It is possible - and easier with a data structure - juste to say "that voxel is positive or negative" and to modify your mesh voxel by voxel (kinda like an painting tool).
    - Use a data structure. I wont go in to much details because its a huge topic, but a good idea is simply to store the density values to make less calculation. But it depends a lot on the project and can be another load on the CPU.
    - Get rid of other load on the CPU. If your only goal is to be able to scultp your mesh you can use a static world (see the static chunk management class).
    - Be carefull with the voxel's size. By default Voxelab use a size of 1 Unity unit by voxel and you can try with 2 by Uunit. Remember that's a float calculation for each voxel ^3 (X Y Z axes) for each density function. And maybe more With Dual Contouring or Marching Cubes as you need linear interpolation and other calculations. So the smaller the voxel is the more precise your mesh will be, but also much more expansive to calculate.
    - Try without multi-threading. If your calculation are mainly limited to the player's input (ie : after world loading and without limitless world) it can be faster to use all your cpu to calculate your new mesh.
    - Direct Computing. To much load on the CPU ? Give it to your graphic card ! It is something to study. Unfortunatly the main reference I used is no longer available (http://forum.unity3d.com/threads/terrible-news-for-unity-community-scrawks-blog-was-deleted.411162/).
    - There is also other options with the meshing algorithms, but you need to look at the SIGGRAPH papers.

    At last it is usefull to remember that Unity is not a scultping tool by default so there are limites. And your CPU capacity is to be taken into account.

    Did I answered your question ? Do you have more ?
     
  39. juuuuun

    juuuuun

    Joined:
    Feb 17, 2014
    Posts:
    23
    Thank you for the detailed answer!

    I will look into all those options you have provided. It's great to know.

    I have one more question if you could tell me.
    I have recently checked encountered a web called voxelpaint.com which seems to achieve the stuff I want.
    I have also used a VR app for HTC Vive called ScultrVR which is also what I want to achieve.
    Which of the options you have mentioned could be used to achieve the effect which is used in above two
    programs?

    Thank you,
     
  40. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    For voxelpain.com, its a much less expansive software. While your mouse button is down the frequence of sphere creation is lower than what Voxelab is allowing. Also it is using the boxel algorithm which is very quick. And it dont seems to have a world isosurface.
    You probably just need to lower the frequency between two sphere creation or mesh calculation (ie not remaking the mesh after each new sphere). Maybe choose a faster meshing script, try different voxel's size. All those things are available by default with Voxelab.

    I don't know ScultVR but I made some research on Occulus Medium. If this is the kind of very precise sculting you are looking for, you won't have it with Voxelab. You will probably need a low voxel size (ie a lot of voxels) ans the more precise versions of procedural meshings scripts. For that you should look at the last SIGGRAPH papers.
     
    Last edited: Sep 1, 2016
  41. Streamfall

    Streamfall

    Joined:
    Aug 8, 2011
    Posts:
    43
    Hello Voxel folks -
    I have been trying to build a marching cubes implementation which is somewhat similar to yours. I've hit a stumbling block however, with resolution. I've managed to get the chunks to change not only size but also resolution, where a quad is not just 1 x 1 but lets say 5x5 instead. However, I've had trouble making them load at that resolution.

    I want to do this so I can work with mobile.

    You have some interesting features, such as threading.

    I wonder if your plugin supports a resolution multiplier, so that the chunks and density can be presented larger.

    Is this something your plugin supports?



    pt 2)
    I have sort of answered my own question. I found smoothing.
    However, this does the reverse of what I was hoping for. So, I tried multiplying instead of dividing in this line in 'WorldRuning.cs"
    World.Instance.VoxelSize=1.0f/World.Instance.Smoothing; //numberofvoxelbyUnity unit
    to...
    World.Instance.VoxelSize=1.0f*World.Instance.Smoothing; //numberofvoxelbyUnity unit

    This worked great! Except... chunking doesn't work correctly any more. Any hints?

    Thanks!


    pt 3)
    Update :
    I figured it out.
    Line 211 from ChunkManager.cs. EndPos+=(chunkSize*World.Instance.Smoothing)*direction;
    Seems to work. Now I have to ensure that the the resulting noise etc does not take the smoothing height into account, at 4, there are lots of huge spires. Looking into it now.
     
    Last edited: Oct 23, 2016
  42. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Streamfall It seems that you found the answers to your questions.
    I still would like to had some help to your work.

    I guess that by quad you mean a unity Unit (Uunit) cube. By default I use a ratio of 1 voxel by 1 Uunit.
    If you want to calculate more precesly your mesh, by adding more data, you can add more voxel by Uunit and say 2 or 4 (even nombers are better to avoid floating roading issues).
    This means that your voxels compte will be for one cube of nbOfVoxel ^ 3. So you came from 1 voxel/Cube to 2^3 Voxels by cube or 4^3. Wich is a huge amount of calculation. And it can be an issue, especialy on mobile with less calculation power.
    Now you can do the opposate and reduce the number of voxels / Uunit. And for example have 1 voxel for 2 Uunit (ie 0.5 voxel by Uunit). But you will have less data to calculate your mesh.

    And yes, with Voxelab you can modify the voxel's size which increase or reduce the number of voxel's by Uunity. Hence add or remove data to process with the meshing script.
     
  43. Praktikantrop

    Praktikantrop

    Joined:
    Dec 19, 2016
    Posts:
    1
    Hi, is there in toolbox save volume to filesystem tools?
     
  44. KiwyVoxel

    KiwyVoxel

    Joined:
    Jan 14, 2015
    Posts:
    64
    Hello, no there is not. Its full run time.
     
  45. Steamc0re

    Steamc0re

    Joined:
    Nov 24, 2014
    Posts:
    144
    Hey, I just got the meshingTools from Asset Store. I want to use my own mesh to calculate a density - like a blob modelling system.

    I'm a novice so I can't tell from the example Isosurface.cs what the density values that are being calculated represent, or even what the range is.

    If I wanted to do a sphere, for example, why can't I do:
    Code (CSharp):
    1. private float SphereDensity(float x, float y, float z)
    2.     {
    3.         float d = 0;
    4.  
    5.         Vector3 p = new Vector3(x, y, z);
    6.  
    7.         if (Vector3.Distance(p, sphereCenter) < distance)
    8.         {
    9.             d = 1;
    10.         }
    11.  
    12.         return d;
    13. }
    Shouldn't this return the correct density for all points sampled inside a sphere?
     
  46. Angiel

    Angiel

    Joined:
    Jan 6, 2015
    Posts:
    15
    Hi
    I want to buy Voxelab - Complete Edition but I can't access the documentation (page not found...). Is this project always active?