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.
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.
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.
To use the scenes and generate a mesh, follow these steps:
- Open either the
marching_cubes.tscn
orcomputed_marching_cubes.tscn
scene in Godot. - Assign the image you want to process (either
64x64x64.png
or128x128x128.png
) to theDATA
param. - Click on the "Generate" checkbox to start the mesh generation process.
- Tested on Godot Engine 4.3
- A compatible GPU for running the compute shader implementation
- 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.
- Sebastian Lague's YouTube Video on Marching Cubes
- SebLague/Godot-Marching-Cubes on GitHub
- jbernardic/Godot-Smooth-Voxels on GitHub
This project is licensed under the GNU General Public License v3.0. See the LICENSE
file for more details.