DistanceBuffer
Description
- Derived from
-
SampleBufferFloat32 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
ScanlineRangeDefault
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 / Methods
Downsample
Performs downsampling on the samples of this distance buffer.
Each block of 2x2
input samples is downsampled to a single output sample.
+---+---+ | a | b | +---+ +---+---+ => | x | | c | d | +---+ +---+---+
If this distance buffer has a width and/or height that is not divisible by two, samples will be duplicated in order to get a full input sample block for downsampling. If the output opt buffer is too small, overhang samples will be discarded. The input and output buffers can be the same.