No resources/examples for Random Voxel Terrain Generation?

I’ve been looking at making an HTML5 game, and really enjoy Voxel based games. From building games like Minecraft, to undiscovered treasures like Cube World (Sort of an example of what I am trying to make).

I’ve been looking around and cannot seem to find any resources for how to do Random Generation during Real-Time to create a Voxel World. No Man’s Sky uses perlin noise to randomly generation their voxel world, I’d have no idea where to start with it but is that a good idea?

How could I go about to make a randomly generated world?

User @nakata0705 has done a lot of work in PlayCanvas to create a voxel-based ‘game’. Check out his project:

I believe he hosts the app on his own server rather than PlayCanvas. It’s here:

It’s pretty cool!

A problem with dynamically generating world’s is keeping the draw call count low. For example, in the example above, if every voxel was a separate entity (or draw call), it would use too much CPU to render the scene. The solution here was to use voxel.js to generate a single mesh combining many voxels together.

@nakata0705 may also have some advice for you. :smile:

Awesome thank you very much! I was hoping to make a variation of Cube World in the manner that it would be a randomly generated cubed (minecraft/cube world) environment that would eventually be multiplayer. It’s a big undertaking for an Indie but it’s what I enjoy doing and it’s my hobby so yeah.

I could always manipulate code and learn from it, but never create from scratch which always bothered me. And voxels (let alone procedurally generated) is a huge task.

Wouldn’t it be a good method to essentially only render what the user sees? I’m not sure how I’d do it but then the only things being rendered is what the player sees and not the blocks behind, until they are triggered and then become active/rendered. Putting everything in one mesh would be good and all as well but how would that work for destructible terrain? I’d want to pretty much do the way Trove did it, the environment can be broken but certain areas such as specific dungeons cannot be.

The latest version of my code is here. You have to put the code to some web server and run. But even without running it, you should be able to see how to render/add physics to voxel world.

This program already does what you say to some extent “render what the player see effectively” (chunk system + voxel.js greedy mesh generator), “destruct/build voxel world”. Since the program uses 32 bit voxel ID, you should be able to easily make some blocks breakable and some not breakable. You can also use texture atlas with material shader to render fancy voxels.

The fundamental problem I couldn’t resolve was the sudden slowdown of physics engine. This program creates a lot of static rigid bodies as you put voxels in the world. And it seems if there are too many static rigid bodies, the physics simulation slows down occasionally (to be more accurate, very frequently with slow machine) and make the game not playable.

I thought creating static rigid bodies only around dynamic rigid bodies might resolve the issue, but I didn’t have enough time to work on that after I get back to Japan.

But if the physics issue can be resolved, the basis of the voxel world on PlayCanvas is there.

1 Like