Method SampleNormal
| Edit this page View SourceSampleNormal(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.