ZLab.Discrete ZLab.Discrete
ZLab.Discrete ZLab.Discrete
Developed by Zeke Zhang

Search Results for

    Edit this page

    Method SampleNormal

    | Edit this page View Source

    SampleNormal(DistanceGrid, Vector3, bool)

    Returns a unit-length normal estimated from the SDF gradient at a world-space position.

    Declaration
    public static Vector3 SampleNormal(this DistanceGrid grid, Vector3 worldPos, bool clampToBounds = true)
    Parameters
    Type Name Description
    DistanceGrid grid

    Distance grid to sample

    Vector3 worldPos

    Query position in world space.

    bool clampToBounds

    If true, samples outside the grid are clamped to the outermost valid cell; if false, an ArgumentOutOfRangeException is thrown when sampling out of bounds.

    Returns
    Type Description
    Vector3

    Unit normal vector. Returns Zero if the gradient magnitude is near zero.

    Remarks

    Normal is computed as Normalize(SampleGradient(worldPos)). Suitable for shading, collision response, and analysis; accuracy improves with grid resolution.