Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by FrostBladePoro · Mar 22, 2017 at 07:15 AM · terrainvoxelcubesmarching cubes

From Cubes to Marching Cubes | Beginner

Hello,

I'm working around with unity for a few months. I have some experience in java. I'm honest to you. I feel like actually dying. I'm googling, reading, testing for 2 weeks with no solution in sight. If i would see any hope I wouldnt open a post. I'm really desperate.

My plan is to generate a smooth voxel terrain. I've read tutorials and all kind of stuff with voxels and marching cubes for 2 weeks. (b4 I played around with hightmaps and meshes) I'm at the point that I have created a surface simply cloning a prefab cube over and over again and adding a perlin noise. The cubes are only instantiated, not in a array, list, etc.

So how do i actually get from my cubes to marching cubes? I do understand how the algorithm roughly works in theory, but I can't recreate it in C#- I have read Paul Bourke's article several times. I got an idea how it works but i have no idea how to implement it in C# and make it work with my cubes. I have also found some example code, I sadly didn't get it to work. I do somehow understand what some methods will do but I can't recreate it and I don't know how i get from the cubes to the point i can implement a marching cubes algorithm.

I feel like saving the cubes in a 3d array would be a good start.. but what next?

This is how my "terrain" looks like: alt text

voxelterrain.png (421.5 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MD_Reptile · Mar 22, 2017 at 07:16 AM 0
Share

http://www.voxelab.fr/ has some good tutorials/info on voxels and voxel engines in unity, such as marching cubes basics and dual contouring and stuff.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by WireShark77 · Jul 26, 2018 at 06:09 PM

I am trying to figure this out myself, but I think your first step should be creating a single mesh for this 'chunk' of terrain. In order to do this you will need the vertices, uvs, and triangles of the mesh you want to make. I guess you might be able to calculate this from from your cubes however I would recommend checking out Nintendo Examiner's Let's make a voxel game series. One downside to this is that at a few points he makes fixes/changes to his scripts off camera, however you can find them by looking at the script in his video. Also do not use his github download link because it does not work, and his scripts are more complicated than in the tutorial.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Bunny83 · Jul 26, 2018 at 09:05 PM

Well, implementing marching cubes from scretch is quite difficult because it's quite hard to setup the 256 triangle combinations right. Though I'd like to add that if your voxel data is only composed of binary values (a bit like minecraft: occupied or not) then all you need are the 256 cases which are just rotated versions of the 15 base configurations as you can see them on the marching cubes wiki article.All vertices are exactly half way between two corners of an edge. Though when you have a real iso surface things get a bit more complicated. Since each "voxel value" does no longer correspond to occupied or not but each value has a float indicating the "size" of each voxel. You still need the binary representation to pick the right triangle configuration though. This is done by a simple threshold comparison. Once you have picked the configurations the vertices are not just placed at the center of each edge, but are interpolated based on the actual voxel values.


The most tricky part may be to create shared vertices (if you want / need them). Since each edge in the voxel grid is shared by 4 triangle configurations the vertex on that edge belongs to those 4 configurations. It should be also noted that with the 15 case solution there are ambiguous situations (mainly for iso surfaces) which can be resolved by checking the interpolated center like described on page 3 of this paper


Note that it's probably easier to just use an existing solution. Google gave me this one. It has an MIT license. Though if you insist in implementing it yourself that's something you have to decide if you can pull this off or not ^^.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Marching Cubes terrain deformation problem 2 Answers

How can I smoothen my cubic mesh using marching cubes? 0 Answers

Smooth Voxel terrain. How is it done? 2 Answers

How to destroy terrain using Sebastian Lague's Marching Cubes implementation 1 Answer

Voxel terrain - NOT MINECRAFT - Digging and creating with resources 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges