Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.
/ mycraft-unity Public archive

Prototype for an 'infinite' voxel world in Unity

Notifications You must be signed in to change notification settings

d-bucur/mycraft-unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voxel prototype in Unity

Description

My attempt at recreating a basic version of an 'infinite' procedurally generated voxel world.

Controls

  • Left click to build
  • Right click to destroy
  • WASD to move
  • Space to jump
  • Hold shift for speed and jump boost

Details

You can configure most of the details of the world inside the WorldBuilder object, like how big each sector is and how far they are rendered. The world is generated by overlapping a bunch of configurable Perlin noise maps.

For each sector only the visible faces of cubes are generated (the ones facing empty blocks that you can walk in). New sectors are generated during multiple frames trying to maintain a 60 FPS target. The generation is divided into 2 phases that alternate between frames

1.Generate mesh data

Launches in parallel jobs for each sector:

SectorGenerationJob: Fills each block with a type by sampling noise maps and overriding values with player modifications

MeshGenerationJob: Sweeps the generated blocks to generate data for visible faces

2.Create Unity meshes

Given data from the jobs in the previous phase, this creates a collision mesh for the terrain, and launches a job to bake it for usage with a mesh collider

While the jobs finish, render meshes are created and assigned