How to get a "Cube World" generation?

Hi all,

So today I did some research on how to get a terrain generation that
looks a bit like this"

Basically all I found was outdated tutorials and stuff
by the coding language Lua. (Which is not in Unity…)

How can I get a “Cube World” feel/terrain for a game I am planning to make?

You’re talking about a voxel engine I take it.

There are a good number of resources available to walk you through it - I would start with this one:

That one is a good introduction to how voxel engines work and creating procedural meshes, and then you will be able to take it your own way from there.

1 Like

I have looked at Alex’s tutorial and I tried it on Unity in C# but I think its “outdated”

I’m not sure how it’s outdated. The same principles still apply - grouping blocks into chunks and creating meshes based off of those chunks, as well as using noise algorithms to create the terrain.

Is there a specific problem you ran into?

Hmm. I guess the thing i’m looking for is how to create random noise… stuff lol

You should use Perlin noise.

You can use 2D perlin noise to create a heightmap and 3D noise to carve out caves or add overhangs.

Alex’s tutorial does cover how to do this in part 6 → http://alexstv.com/index.php/posts/unity-voxel-block-tutorial-pt-6

(He doesn’t cover caves until section 8, though).

He uses Simplex Noise, but Perlin works in about the same exact way and is a bit faster.

Have you looked at that? If so, if you have a specific problem you’re stuck with, I can try to help.

1 Like

Isn’t Simplex supposed to be less computationally expensive?

O(n^2) in 3D for Simplex = 3^2 = 9
O(2^n) in 3D for Perlin = 2^3 = 8.

In higher dimensions, Simplex is better.

2 Likes

Voxels it is. There are assets out there. Or you can search any general tutorial on voxels.

How is it a bit faster? With 2D simplex noise you only need to evaluate between 3 points compared to perlin’s 4, and in 3D space you only need 4 points compared to perlin’s 8. I find it hard to believe perlin will be faster in any space if both implementations were similarly optimized.

You’re probably right. I will say, though, that I think it doesn’t matter much for the 3D case. I think that how optimized the implementation you’re using is will be a larger determinant of how well it performs.

In my case I use a very well optimized Perlin noise implementation, which tends to perform better than the Simplex implementations I can find based on my personal observations.

Speaking of implementations, there’s a library for various noise types that uses the GPU on the Asset Store for free.

And just for the record, terrain like stuff normally only needs 2D noise.

but it may need some 3D noise to make it looks like rock

And when the guy said things are outdated (not sure how outdated), yes the same principles still apply, however, when Unity 5 came out didn’t they depreciate some of the old things and no longer work now but just a slight different change and work again?

Mainly things relevant to a voxel engine:

-Any use of .renderer or .rigidbody, etc. has to be changed to GetComponent() and the like.

-Locking cursor to the center of the screen changed.

-Transparency shaders will need to specify keepalpha for transparent blocks.

Not much, really. But there’s always the upgrade guide.

1 Like