docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class MeshToSDFBaker

    This class allows to bake Signed Distance Fields from Meshes, and holds the necessary data to perform this operation.

    Inheritance
    object
    MeshToSDFBaker
    Implements
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.VFX.SDF
    Assembly: Unity.VisualEffectGraph.Runtime.dll
    Syntax
    public class MeshToSDFBaker : IDisposable

    Constructors

    MeshToSDFBaker(Vector3, Vector3, int, List<Mesh>, List<Matrix4x4>, int, float, float, CommandBuffer)

    Constructor of the class MeshToSDFBaker.

    Declaration
    public MeshToSDFBaker(Vector3 sizeBox, Vector3 center, int maxRes, List<Mesh> meshes, List<Matrix4x4> transforms, int signPassesCount = 1, float threshold = 0.5, float sdfOffset = 0, CommandBuffer cmd = null)
    Parameters
    Type Name Description
    Vector3 sizeBox

    The desired size of the baking box

    Vector3 center

    The center of the baking box.

    int maxRes

    The resolution along the largest dimension.

    List<Mesh> meshes

    The list of meshes to be baked into an SDF.

    List<Matrix4x4> transforms

    The list of transforms of the meshes.

    int signPassesCount

    The number of refinement passes on the sign of the SDF. This should stay below 20.

    float threshold

    The threshold controlling which voxels will be considered inside or outside of the surface.

    float sdfOffset

    The Offset to add to the SDF. It can be used to make the SDF more bulky or skinny.

    CommandBuffer cmd

    The CommandBuffer on which the baking process will be added.

    MeshToSDFBaker(Vector3, Vector3, int, Mesh, int, float, float, CommandBuffer)

    Constructor of the class MeshToSDFBaker.

    Declaration
    public MeshToSDFBaker(Vector3 sizeBox, Vector3 center, int maxRes, Mesh mesh, int signPassesCount = 1, float threshold = 0.5, float sdfOffset = 0, CommandBuffer cmd = null)
    Parameters
    Type Name Description
    Vector3 sizeBox

    The desired size of the baking box.

    Vector3 center

    The center of the baking box.

    int maxRes

    The resolution along the largest dimension.

    Mesh mesh

    The Mesh to be baked into an SDF.

    int signPassesCount

    The number of refinement passes on the sign of the SDF. This should stay below 20.

    float threshold

    The threshold controlling which voxels will be considered inside or outside of the surface.

    float sdfOffset

    The Offset to add to the SDF. It can be used to make the SDF more bulky or skinny.

    CommandBuffer cmd

    The CommandBuffer on which the baking process will be added.

    Properties

    SdfTexture

    Returns the texture containing the baked Signed Distance Field

    Declaration
    public RenderTexture SdfTexture { get; }
    Property Value
    Type Description
    RenderTexture

    Methods

    BakeSDF()

    Performs the baking operation. After this function is called, the resulting SDF is accessible via the property MeshToSDFBaker.SdfTexture.

    Declaration
    public void BakeSDF()

    Dispose()

    Release all the buffers and textures created by the object. This must be called you are finished using the object.

    Declaration
    public void Dispose()

    ~MeshToSDFBaker()

    This finalizer should never be called. Dispose() should be called explicitly when an MeshToSDFBaker instance is finished being used.

    Declaration
    protected ~MeshToSDFBaker()

    GetActualBoxSize()

    Gets the size of the baking box used.

    Declaration
    public Vector3 GetActualBoxSize()
    Returns
    Type Description
    Vector3

    A Vector3 containing the size of the box along the three directions of space

    GetGridSize()

    Gets the dimensions of the baked texture.

    Declaration
    public Vector3Int GetGridSize()
    Returns
    Type Description
    Vector3Int

    A Vector3Int containing the height, width and depth of the texture.

    Reinit(Vector3, Vector3, int, List<Mesh>, List<Matrix4x4>, int, float, float)

    Reinitialize the baker with the new lists of meshes and transforms, and provided parameters.

    Declaration
    public void Reinit(Vector3 sizeBox, Vector3 center, int maxRes, List<Mesh> meshes, List<Matrix4x4> transforms, int signPassesCount = 1, float threshold = 0.5, float sdfOffset = 0)
    Parameters
    Type Name Description
    Vector3 sizeBox

    The desired size of the baking box

    Vector3 center

    The center of the baking box.

    int maxRes

    The resolution along the largest dimension.

    List<Mesh> meshes

    The list of meshes to be baked into an SDF.

    List<Matrix4x4> transforms

    The list of transforms of the meshes.

    int signPassesCount

    The number of refinement passes on the sign of the SDF. This should stay below 20.

    float threshold

    The threshold controlling which voxels will be considered inside or outside of the surface.

    float sdfOffset

    The Offset to add to the SDF. It can be used to make the SDF more bulky or skinny.

    Reinit(Vector3, Vector3, int, Mesh, int, float, float)

    Reinitialize the baker with the new mesh and provided parameters.

    Declaration
    public void Reinit(Vector3 sizeBox, Vector3 center, int maxRes, Mesh mesh, int signPassesCount = 1, float threshold = 0.5, float sdfOffset = 0)
    Parameters
    Type Name Description
    Vector3 sizeBox

    The desired size of the baking box.

    Vector3 center

    The center of the baking box.

    int maxRes

    The resolution along the largest dimension.

    Mesh mesh

    The Mesh to be baked into an SDF.

    int signPassesCount

    The number of refinement passes on the sign of the SDF. This should stay below 20.

    float threshold

    The threshold controlling which voxels will be considered inside or outside of the surface.

    float sdfOffset

    The Offset to add to the SDF. It can be used to make the SDF more bulky or skinny.

    Implements

    IDisposable
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)