DistanceBuffer

Description

sealed class Tinman.Terrain.Buffers.DistanceBuffer

Derived from

FloatBuffer abstract

A distance buffer stores signed distance values towards the border of a two-dimensional shape (negative is inside).

Distance textures can be used for high-quality rendering of shapes (for example terrain decals). The samples in a distance buffer have a pixel-is-area semantic (see PixelCoverage.PixelIsArea): The sample value is the distance from the center of the sample area towards the nearest point on the shape border.

Public / Constants

Scanline​Range​Default


public static readonly attribute ScanlineRangeDefault → (PixelRange)

The default value of ISampleBuffer.ScanlineRange.

The distance value range is exploited during rasterization: regions that only contain distance values below the minimum bound or above the maximum bound will be skipped.

For image coding, the raw pixel value corresponds to the signed distance value.

The default pixel range maps signed distance values as follows:
-1 : 16777215 (i.e. maximum pixel channel value when inside of shape)
+1 : 0 (i.e. minimum pixel channel value when outside of shape).

Public / Constructors

Distance​Buffer


public constructor DistanceBuffer → (2)

width in : int32

[>0]
The buffer width, in samples.

height in : int32

[>0]
The buffer height, in samples.

Creates a new instance of DistanceBuffer.

Public / Methods

Encode​Pixels

2 overloads


public method EncodePixels1 → (2)

ramp in : IColorRamp

[not-null]
The color ramp to use for mapping signed distance values to pixel colors.

buffer opt : ColorBuffer = null

The output buffer or null to create a new one.

returns → ColorBuffer

The encoded pixel buffer.

Encodes the signed distances in this buffer into pixels.


public method EncodePixels2 → (3)

ramp in : IColorRamp

[not-null]
The color ramp to use for mapping signed distance values to pixel colors.

buffer in : ColorBuffer

The output buffer or null to create a new one.

colorOp in : ColorOp

The ColorOp to use to combine the samples in buffer in (first) with the encoded pixels (second).

returns → ColorBuffer

buffer in

Encodes the signed distances in this buffer into pixels.