# How can I convert Marching squares to marching cubes?

Hi everyone,

I want to create a 3d procedural terrain which can be modified by the player. For so far I have found, this should be able to be done by using marching cubes. Now, I haven't found any tutorials that are clear, still online or up-to-date about marching cubes. I did however, find that the marching squares algorithm is a good start for what I want and should be able to later be developed into marching cubes. And I also found out that if I make a voxel engine, I should be able to convert it to the terrain I want. Is this true, or is it something differing?

So I currently am following the marching squares (procedural cave) tutorial of Unity self, but I am wondering on how I can convert from the marching squares into the marching cubes. How can I do this? Is there a good tutorial for this already and if so, could someone please provide the link for this to me?

Thanks,

**Answer** by Bunny83
·
Jan 24 at 01:54 AM

Even though marching squares and marching cubes are based on the same idea they need to be implemented completely different. Also marching cubes has more ambigous cases that are more complicated than with the marching squares. There are plenty of sites explaining the algorithm like this one or this one. The second site (Paul Bourke) has an example implementation written in C++. Paul Bourke's implementations of many common math and graphics related algorithms are **the** reference implementations for years now.

So even marching squares is related / shares the same idea as the marching cubes algorithm, "converting" one into the other just isn't possible. Knowing how to build a sand castle doesn't really help building a real castle, even they have many things in common.

Ahh, I see. Didn't know about marching- cubes and squares having such a difference. Your example made it clearer. Thanks for that ;)

I have seen Paul's one, but might have read through it to quickly and discarded the site. Now, I've read it again and found it useful though.

The only thing is that I wan't to make procedural terrain out of it and correct me if I am wrong, but the tutorials don't explain how I can do that, do they? Do I need to use a voxel engine for it in which I later implement the marching cubes?

Thanks for the effort ;)

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.