Skip to content

Cubes on the March: Godot 4 CPU & GPU Marching Cubes Implementation

License

Notifications You must be signed in to change notification settings

jeronimo-schreyer/godot-marching-cubes

Repository files navigation

Cubes on the March

Godot 4 CPU & GPU Marching Cubes Implementation

This project is an implementation of the Marching Cubes algorithm using both CPU and GPU (compute shaders). It aims to demonstrate the performance differences and techniques between the two approaches in generating 3D meshes from volumetric data.

Project Structure

The project contains two main scenes:

  • res://marching_cubes.tscn: Implementation of the Marching Cubes algorithm using the CPU.
  • res://computed_marching_cubes.tscn: Implementation of the Marching Cubes algorithm using the GPU with compute shaders.

Data Sources

Two images are provided as volumetric data sources (Texture3D) for mesh generation:

  • res://data/64x64x64.png
  • res://data/128x128x128.png

Each image is a spritesheet containing vertical slices of Suzanne that will be processed by the algorithm to generate the mesh.

Usage

To use the scenes and generate a mesh, follow these steps:

  1. Open either the marching_cubes.tscn or computed_marching_cubes.tscn scene in Godot.
  2. Assign the image you want to process (either 64x64x64.png or 128x128x128.png) to the DATA param.
  3. Click on the "Generate" checkbox to start the mesh generation process.

Captura de pantalla 2024-08-05 160152

Requirements

  • Tested on Godot Engine 4.3
  • A compatible GPU for running the compute shader implementation

Notes

  • The CPU implementation is suitable for understanding the basic workings of the Marching Cubes algorithm.
  • The GPU implementation showcases how compute shaders can be utilized for improved performance in processing volumetric data.

References

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for more details.

About

Cubes on the March: Godot 4 CPU & GPU Marching Cubes Implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published