Skip to content

Add foundational voxel engine: generic, terrain, and smooth voxel support#40

Draft
Copilot wants to merge 7 commits intomainfrom
copilot/add-foundational-voxel-systems
Draft

Add foundational voxel engine: generic, terrain, and smooth voxel support#40
Copilot wants to merge 7 commits intomainfrom
copilot/add-foundational-voxel-systems

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 18, 2025

Implements core voxel engine systems supporting discrete blocky materials, density-based terrain, and smooth surfaces via Marching Cubes. Designed for extensibility (LOD, streaming, editing).

Core Data Structures

  • VoxelData: Density (fp16), material ID, flags. 4 bytes per voxel.
  • ChunkData: 3D voxel grid (default 32³), flat array with indexing helpers, mesh references, NativeArray support for Jobs.

Meshing Pipeline

  • GreedyMeshingJob: Face culling for blocky voxels. Burst-compiled, zero GC.
  • MarchingCubesJob: Simplified MC prototype for smooth terrain. Burst-compiled, zero GC. Full lookup tables noted for future implementation.
  • IMeshingJob: Interface for pluggable meshing algorithms.

Chunk Management

  • ChunkManager: Spatial hash, automatic job scheduling, world/local coordinate conversion, smart mesher selection (blocky vs smooth).

Example Usage

ChunkManager manager = gameObject.AddComponent<ChunkManager>();
manager.ChunkMaterial = material;

// Blocky voxels
manager.SetVoxel(new int3(x, y, z), VoxelData.CreateSolid(materialId: 1));

// Smooth terrain with density field
manager.SetVoxel(new int3(x, y, z), VoxelData.CreateSmooth(density: 0.7f, materialId: 2));

// Meshes generate automatically via Jobs

Implementation Notes

  • Half precision density saves 50% memory (68KB vs 128KB per 32³ chunk)
  • Sequential job processing for simplicity; parallelizable via NativeList
  • MC uses basic surface approximation; full 256-entry tables commented for production use
  • Assembly references added: Unity.Burst, Unity.Collections, Unity.Jobs, Unity.Mathematics

Includes 15 unit tests, 3 example demos, and architecture documentation (ARCHITECTURE.md, README.md).

Original prompt

This section details on the original issue you should resolve

<issue_title>Foundational voxel engine systems: Generic, Terrain, and Smoothed voxel support</issue_title>
<issue_description>## Is your feature request related to a problem? Please describe.
To develop a robust voxel engine that can support discrete blocky materials and natural, smooth terrain, foundational systems must be established. The engine should be extensible, high performance, and capable of both grid-based and density-based voxel representations.

Describe the solution you'd like

This feature should establish core systems for a voxel engine supporting:

  • Generic voxels (blocky, discrete materials)
  • Terrain voxels (density fields for natural landscapes)
  • Smoothed voxels (continuous surfaces via Marching Cubes or Dual Contouring)

The initial implementation should provide:

  • Data structures for different voxel types
  • Chunk management for spatial partitioning
  • Meshing pipeline hooks to support future LOD, streaming, and editing features

Tasks

  • Define Voxel struct with density, material ID, and flags
  • Implement Chunk class with chunk coordinates, voxel storage, and mesh references
  • Add indexing helpers for 3D voxel arrays
  • Create placeholder meshing jobs:
    • Greedy meshing for blocky voxels
    • Marching Cubes prototype for smooth terrain
  • Integrate Unity Jobs + Burst for meshing execution
  • Generate meshes per chunk and assign to MeshFilter/MeshCollider
  • Document architecture decisions (chunk size, density representation, meshing choice)

Requirements & Notes

  • Meshing must run off the main thread via Jobs + Burst.
  • Code should be structured for extensibility (future LOD, streaming, editing).
  • Keep chunk size configurable (default 32³).
  • Use Half (fp16) for density to balance precision and memory.
  • Mesh generation can be minimal (cubes + basic Marching Cubes), but must demonstrate both blocky and smooth paths.
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 6 commits December 18, 2025 16:41
Co-authored-by: dyfios <16926525+dyfios@users.noreply.github.com>
Co-authored-by: dyfios <16926525+dyfios@users.noreply.github.com>
Co-authored-by: dyfios <16926525+dyfios@users.noreply.github.com>
…ions

Co-authored-by: dyfios <16926525+dyfios@users.noreply.github.com>
Co-authored-by: dyfios <16926525+dyfios@users.noreply.github.com>
Co-authored-by: dyfios <16926525+dyfios@users.noreply.github.com>
Copilot AI changed the title [WIP] Add foundational voxel engine systems for generic and terrain support Add foundational voxel engine: generic, terrain, and smooth voxel support Dec 18, 2025
Copilot AI requested a review from dyfios December 18, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Foundational voxel engine systems: Generic, Terrain, and Smoothed voxel support

2 participants