Coder Social home page Coder Social logo

unity-voxel's Introduction

unity-voxel

Voxelize mesh algorithm in Unity. (includes GPU and CPU voxelizers.)

Demo

GPUVoxelParticleSystem

GPUVoxelParticleSystem

the Demo for GPU Particle with geometry shader. (only tested on windows10 (GTX 1060))

Inspired by Keijiro Takahashi works⚡️ StandardGeometryShader & KvantSpray

GPUVoxelMosaic

GPUVoxelMosaicLevels

GPUVoxelMosaic

the Demo to update the resolution of voxels in realtime. (only tested on windows10 (GTX 1060))

GPUVoxelSkinnedMesh

GPUVoxelSkinnedMesh

Sample a mesh from SkinnedRenderer in every frame and voxelize it in realtime.

the human model and animation from asset store.

Usage

with GPU Voxelizer (recommended)

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<MeshFilter>().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

// Voxelize target mesh with CPU Voxelizer

List<Voxel> 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

unity-voxel's People

Contributors

mattatz avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.