Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattatz/unity-voxel
Mesh voxelization for Unity.
https://github.com/mattatz/unity-voxel
Last synced: 10 days ago
JSON representation
Mesh voxelization for Unity.
- Host: GitHub
- URL: https://github.com/mattatz/unity-voxel
- Owner: mattatz
- License: mit
- Created: 2016-10-07T03:42:50.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-06T03:58:26.000Z (almost 6 years ago)
- Last Synced: 2024-10-01T13:04:25.329Z (about 1 month ago)
- Language: C#
- Size: 114 MB
- Stars: 1,402
- Watchers: 55
- Forks: 151
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-unity-open-source-on-github - unity-voxel - Mesh voxelization (Voxel)
README
unity-voxel
=====================Voxelize mesh algorithm in Unity. (includes GPU and CPU voxelizers.)
![Demo](https://raw.githubusercontent.com/mattatz/unity-voxel/master/Captures/Demo.gif)
## GPUVoxelParticleSystem
![GPUVoxelParticleSystem](https://raw.githubusercontent.com/mattatz/unity-voxel/master/Captures/GPUVoxelParticleSystem.gif)
the Demo for GPU Particle with geometry shader. (only tested on windows10 (GTX 1060))
Inspired by Keijiro Takahashi works⚡️ [StandardGeometryShader](https://github.com/keijiro/StandardGeometryShader) & [KvantSpray]( https://github.com/keijiro/KvantSpray)
## GPUVoxelMosaic
![GPUVoxelMosaicLevels](https://raw.githubusercontent.com/mattatz/unity-voxel/master/Captures/GPUVoxelMosaicLevels.gif)
![GPUVoxelMosaic](https://raw.githubusercontent.com/mattatz/unity-voxel/master/Captures/GPUVoxelMosaic.gif)
the Demo to update the resolution of voxels in realtime. (only tested on windows10 (GTX 1060))
## GPUVoxelSkinnedMesh
![GPUVoxelSkinnedMesh](https://raw.githubusercontent.com/mattatz/unity-voxel/master/Captures/GPUVoxelSkinnedMesh.gif)
Sample a mesh from SkinnedRenderer in every frame and voxelize it in realtime.
the human model and animation from [asset store](https://assetstore.unity.com/packages/3d/animations/raw-mocap-data-for-mecanim-5330).
## Usage
with GPU Voxelizer (recommended)
```cs
GPUVoxelData data = GPUVoxelizer.Voxelize(
voxelizer, // ComputeShader (Voxelizer.compute)
mesh, // a target mesh
64, // # of voxels for largest AABB bounds
true // flag to fill in volume or not; if set flag to false, sample a surface only
);// build voxel cubes integrated mesh
GetComponent().sharedMesh = VoxelMesh.Build(data.GetData(), data.UnitLength, useUV);// build 3D texture represent a volume by voxels.
RenderTexture volumeTexture = GPUVoxelizer.BuildTexture3D(
voxelizer,
data,
texture, // Texture2D to color voxels based on uv coordinates in voxels
RenderTextureFormat.ARGBFloat,
FilterMode.Bilinear
);// need to release a voxel buffer
data.Dispose();
```with CPU Voxelizer
```cs
// Voxelize target mesh with CPU VoxelizerList voxels = CPUVoxelizer.Voxelize(
mesh, // a target mesh
20 // # of voxels for largest AABB bounds
);
```## Compatibility
Tested on Unity 2018.3.0f2, windows10 (GTX 1060), macOS (metal, not compatible with GPU Particle Demo).
## Sources
- Triangle mesh voxelization / Wolfire Games Blog - http://blog.wolfire.com/2009/11/Triangle-mesh-voxelization
- Möller–Trumbore intersection algorithm - https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
- keijiro/StandardGeometryShader - https://github.com/keijiro/StandardGeometryShader
- keijiro/KvantSpray - https://github.com/keijiro/KvantSpray
- Post Processing Stack - https://www.assetstore.unity3d.com/jp/#!/content/83912