Giter Site home page Giter Site logo

domigome / com.unity.demoteam.mesh-to-sdf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unity-technologies/com.unity.demoteam.mesh-to-sdf

0.0 0.0 0.0 6.49 MB

A light and fast real-time SDF generator, primarily for animated characters. The dynamic SDF can be used for all sorts of VFX. Also enables hair-to-character collisions in the new hair package.

License: Other

C# 80.30% HLSL 16.79% ShaderLab 2.92%

com.unity.demoteam.mesh-to-sdf's Introduction

Package: com.unity.demoteam.mesh-to-sdf

A real-time Signed Distance Field generator. Use a Mesh or a dynamically deforming SkinnedMesh as input to generate a 3D SDF texture every frame.

The SDF can be used by the VFX Graph, the Hair system, and other effects relying on SDFs.


mesh-to-sdf

The generator is real-time - to achieve better performance, it sacrifices robustness and the ability to handle large meshes. Typical resolutions would be a 5-8k triangle mesh in a 16^3-64^3 voxel volume. If your mesh is much larger or messy (holes, spiky shapes, etc.), it's best to use a cleaner low-res proxy mesh instead. Note that the SDF generator shipping with the VFX Graph has a more robust handling of larger or messy meshes, but it's slower.

The generator works by first splatting distances into voxels in a small area around each triangle, then using either a linear flood or jump flood to fill the rest of the volume.

Performance

Tested with a 32^3 voxel volume, 5k triangle mesh

  • jump flood: RTX3090 0.22ms
  • linear flood, 8 iterations: RTX3090 0.18ms, RTX2080Super 0.21ms

Requirements

  • Unity 2021.2+ (mesh buffer access in compute shaders)
  • Compute shaders supported on target platform

Installation

Use Add package from git URL (in the Package Manager):

https://github.com/Unity-Technologies/com.unity.demoteam.mesh-to-sdf.git

or

Declare the package as a git dependency in Packages/manifest.json:

"dependencies": {
    "com.unity.demoteam.mesh-to-sdf": "https://github.com/Unity-Technologies/com.unity.demoteam.mesh-to-sdf.git",
    ...
}

Documentation

Quickstart

Examples

Samples included with the package show basic setup and are described in the doc above.

The mesh-to-sdf examples project is a vfx demo, with the dynamic SDFs driving VFX Graph effects and a raymarching shader:

mesh-to-sdf.mov

Acknowledgements

The core functionality of the generator (initial splatting of distances around mesh faces) uses the implementation from TressFX published by AMD under the MIT license. Thank you!

Known issues

Limitations and known issues

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.