Giter VIP home page Giter VIP logo

signed-distance-field-generator's Introduction

Signed Distance Field Generator

A Unity tool to generate signed distance field volumes (as Texture3D assets) from meshes.

demo

To Install

Download the .unitypackage, or clone this repository.

Tested on Unity 2018.4, should work on earlier and later versions as well. Requires a GPU that supports Compute shaders.

To Use

  1. Select Signed Distance Field > Generator from the Unity menu bar, the tool window will pop up.
  2. Press Create and a save dialog will pop up.
  3. Choose a location and name to save your SDF as.

Options

Mesh: the mesh you want to make an SDF from.

Resolution: the resulting Texture3D resolution (I recommend you keep this below 64).

Submesh Index: for multi-part meshes, the index of the submesh you want to use.

Padding: the padding to surround your mesh within the SDF (only set this to be non-zero if you see artifacts).

Method: the method used to determine the sign of each voxel (only use DotProduct if IntersectionCounter yields artifacts).

To Visualize

I also included a simple raymarching shader to visualize the resulting SDFs.

  1. Drag a cube primitive into the scene, and set its Transform position to (0, 0, 0).
  2. Change its material to SDF > Materials > SignedDistanceField_Visualizer.
  3. Drag one of your created SDF assets into the Volume slot of the material.
  4. Adjust the other material parameters as necessary.

Render As Solid: renders the SDF as a solid object with a simple Lambertian shading model.

Density: adjusts the density of the solid when Render As Solid is turned off.

Maximum Steps: sets the number of steps taken when raytracing through the volume. Setting this requires some trial and error. Too small and detail is lost as sample positions are missed when tracing. Too big and performance suffers.

signed-distance-field-generator's People

Contributors

danielshervheim avatar

Watchers

 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.