Class DistanceFieldConventions
Contains constants and special names that are expected to be used in compatible shaders and assets.
[PublicAPI]
public static class DistanceFieldConventions
- Inheritance
-
DistanceFieldConventions
- Inherited Members
Fields
PerspectiveAwarePixelRangeKeyword
public const string PerspectiveAwarePixelRangeKeyword = "_PERSPECTIVE_AWARE_PIXEL_RANGE"
Field Value
PixelRangeBoneName
Name of the bone that stores the pixel range on its length, which is present on the UnityEngine.Sprites representing distance fields.
public const string PixelRangeBoneName = "_DistanceField_PixelRange"
Field Value
PixelRangeSourceKeywordPrefix
Common part of the shader keyword that specifies from where the shader should fetch the pixel range.
public const string PixelRangeSourceKeywordPrefix = "_PIXEL_RANGE_SOURCE"
Field Value
Methods
GetDistanceFieldPropertyNames(Material)
List all property names of the given material that are expected to be distance fields.
public static string[] GetDistanceFieldPropertyNames(Material material)
Parameters
material
MaterialMaterial to query.
Returns
- string[]
GetDistanceFormat(TextureFormat)
Returns the likely distance field format this texture can store.
public static DistanceFieldFormat GetDistanceFormat(this TextureFormat format)
Parameters
format
TextureFormatFormat to inspect
Returns
Remarks
Does not mean the texture data itself is a valid distance field!
GetKeywordSuffix(PixelRangeSource)
The string that joined to PixelRangeSourceKeywordPrefix with an underscore produces the shader keyword name for this source.
public static string GetKeywordSuffix(this DistanceFieldConventions.PixelRangeSource self)
Parameters
Returns
GetPixelRange(Sprite)
Gets the pixel range of this sprite, or null if it is not present.
public static float? GetPixelRange(this Sprite sprite)
Parameters
sprite
Sprite
Returns
GetPixelRangePlacement(Material)
Finds out how a material is set up to receive the distance field's pixel range.
public static DistanceFieldConventions.PixelRangeSource? GetPixelRangePlacement(Material material)
Parameters
material
MaterialThe material to query.
Returns
- DistanceFieldConventions.PixelRangeSource?
A non-null value if the material appears to expect the pixel range in a known DistanceFieldConventions.PixelRangeSource.
GetPixelRangePropertyName(string)
Returns the property name for a given texture property's pixel range.
public static string GetPixelRangePropertyName(string fieldPropertyName)
Parameters
fieldPropertyName
stringThe distance field texture property.
Returns
IsVertexData(PixelRangeSource)
Is this source informed through vertex data or material property?
public static bool IsVertexData(this DistanceFieldConventions.PixelRangeSource self)
Parameters
Returns
SetPixelRange(Sprite, int)
Sets the pixel range of this sprite. If a bone named PixelRangeBoneName already exists, it is updated, otherwise it is created.
public static void SetPixelRange(this Sprite sprite, int pixelRange)
Parameters
sprite
SpritepixelRange
int