All Projects → Scrawk → Marching Cubes On The Gpu

Scrawk / Marching Cubes On The Gpu

Licence: mit
A implementation of the marching cubes algorithm on the GPU in Unity.

Projects that are alternatives of or similar to Marching Cubes On The Gpu

Marching Cubes Terrain
Marching Cubes terrain implementation in Unity using the Job System and the Burst compiler
Stars: ✭ 292 (+40.38%)
Mutual labels:  unity, voxel
Proceduralterrain
Procedural voxel terrain generation in Unity
Stars: ✭ 237 (+13.94%)
Mutual labels:  unity, voxel
Marching Cubes
Marching cubes in Unity
Stars: ✭ 263 (+26.44%)
Mutual labels:  unity, voxel
Gpu Physics Unity
Through this configuration, no per voxel data is transferred between the GPU and the CPU at runtime.
Stars: ✭ 342 (+64.42%)
Mutual labels:  unity, voxel
Dungeontemplatelibrary
🌏: Dungeon free resources (terrain & roguelike generation)
Stars: ✭ 595 (+186.06%)
Mutual labels:  unity, voxel
Voxelframework
An awesome Voxel framework for Unity (Game Engine)
Stars: ✭ 57 (-72.6%)
Mutual labels:  unity, voxel
Voxelengine unity
Voxel engine made in C# for Unity
Stars: ✭ 25 (-87.98%)
Mutual labels:  unity, voxel
Unityraymarching
Unity Raymarching Examples
Stars: ✭ 57 (-72.6%)
Mutual labels:  unity, voxel
Xuui
xLua的mvvm框架,支持ugui,ngui,fairyGUI。。。
Stars: ✭ 199 (-4.33%)
Mutual labels:  unity
Unitypackage Custom Hierarchy
Unity package to help having a clearer Hierarchy view, organizing everything in a “tree view” and including extra informations like Components Icons and groups/divisors.
Stars: ✭ 202 (-2.88%)
Mutual labels:  unity
Fluent State Machine
Fluent API for creating state machines in C#
Stars: ✭ 195 (-6.25%)
Mutual labels:  unity
Unity Shaders
✨ Shader demo - More than 300 examples
Stars: ✭ 198 (-4.81%)
Mutual labels:  unity
Shinyeffectforugui
Shiny effect of uGUI, which does not need mask or normal map.
Stars: ✭ 204 (-1.92%)
Mutual labels:  unity
Unity.library.eppz.geometry
2D Geometry for Unity. Suited for everyday polygon hassle. Polygon clipping, polygon winding direction, polygon area, polygon centroid, centroid of multiple polygons, line intersection, point-line distance, segment intersection, polygon-point containment, polygon triangulation, polygon Voronoi diagram, polygon offset, polygon outline, polygon buffer, polygon union, polygon substraction, polygon boolean operations, and more. It is a polygon fest.
Stars: ✭ 198 (-4.81%)
Mutual labels:  unity
Nice Lua
基于xlua的MVVM框架,支持Addressables, 统一渲染管线等Unity新特性
Stars: ✭ 207 (-0.48%)
Mutual labels:  unity
Unityparticlesystempreview
Unity ParticleSystem Preview 粒子预览插件
Stars: ✭ 195 (-6.25%)
Mutual labels:  unity
Pumkinsavatartools
A toolbox for easily setting up VRChat avatars in Unity. Adds functionality to the editor and automates some of the tedious tasks.
Stars: ✭ 192 (-7.69%)
Mutual labels:  unity
Unity Portal Rendering
Super small example of using offscreen render targets to achieve a portal effect in Unity
Stars: ✭ 206 (-0.96%)
Mutual labels:  unity
Pix2vox
Sketch-Based 3D Exploration with Stacked Generative Adversarial Networks
Stars: ✭ 206 (-0.96%)
Mutual labels:  voxel
Delight
Delight is an open source component-oriented framework for Unity.
Stars: ✭ 201 (-3.37%)
Mutual labels:  unity

Marching-Cubes-On-The-GPU

This project generates voxels and the mesh all on the GPU using a compute shader version of the marching cubes algorithm. The voxels are generated using a version of the improved Perlin noise done previously but running in a compute shader.

For practically reasons it maybe best to do this sort of thing using multi-threading on the CPU but I though it would still be useful to have a version running on the GPU. I have also included some code in the script to read back the generated mesh from the GPU and convert it into a normal mesh. I dont recommend doing this every frame but its there if you need it.

The scene generates 3D noise as the voxel values and then uses the marching cubes algorithm to convert the voxels to a mesh. As the mesh is generated using a compute shader the vertices are written to a compute buffer. Unity's draw procedural method is then used to render the buffer.

Using a buffer does present some issues. The buffer has to be a fixed size but the number of vertices generated is unknown until the algorithm is ran. To get around this I created a buffer that could hold the maximum number of vertices that the marching cubes can generate which is 5 triangles per voxel. When the algorithm runs only the generated vertices will be written to the buffer leaving all other vertices in the buffer as being zero filled. This means that when rendered a vertex shader is run for each vertex but as the triangle's have no area there is no fragment generated. This is a bit inefficient but I have compared the method with a buffer converted to a normal Unity mesh and there does not seem to be any difference in rendering performance. Maybe in a more complex scene it could become a issue. To get around this and only have the generated vertices in the buffer maybe some sort of set up with a append buffer or counter buffer (to generate indices for the vertices) would be better.

I have also added a stage to generate the smoothed normals by using the derivatives of the voxel values and interpolating them based on the vertices position. There is also a second scene that generates a new mesh every frame using 4D Perlin noise to make a animated voxel mesh.

Marching Cubes GPU

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].