Catlike Coding
Unity Code Documentation
Classes | Static Public Member Functions | List of all members
CatlikeCoding.SDFToolkit.SDFTextureGenerator Class Reference

Utility class for generating signed distance field textures from anti-aliased alpha maps. More...

Static Public Member Functions

static void Generate (Texture2D source, Texture2D destination, float maxInside, float maxOutside, float postProcessDistance, RGBFillMode rgbMode)
 Fill a texture with a signed distance field generated from the alpha channel of a source texture. More...
 

Detailed Description

Utility class for generating signed distance field textures from anti-aliased alpha maps.

Although the generator can be used at run-time, the current version isn't convenient nor optimized for it.

Member Function Documentation

static void CatlikeCoding.SDFToolkit.SDFTextureGenerator.Generate ( Texture2D  source,
Texture2D  destination,
float  maxInside,
float  maxOutside,
float  postProcessDistance,
RGBFillMode  rgbMode 
)
static

Fill a texture with a signed distance field generated from the alpha channel of a source texture.

Parameters
sourceSource texture. Alpha values of 1 are considered inside, values of 0 are considered outside, and any other values are considered to be on the edge. Must be readable.
destinationDestination texture. Must be the same size as the source texture. Must be readable. The texture change does not get applied automatically, you need to do that yourself.
maxInsideMaximum pixel distance measured inside the edge, resulting in an alpha value of 1. If set to or below 0, everything inside will have an alpha value of 1.
maxOutsideMaximum pixel distance measured outside the edge, resulting in an alpha value of 0. If set to or below 0, everything outside will have an alpha value of 0.
postProcessDistancePixel distance from the edge within which pixels will be post-processed using the edge gradient.
rgbModeHow to fill the destination texture's RGB channels.