Table of Contents

Class DistanceFieldConventions

Namespace
Kroltan.Keen
Assembly
me.kroltan.keen-vectors.dll

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

string

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

string

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

string

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 Material

Material 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 TextureFormat

Format to inspect

Returns

DistanceFieldFormat

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

self DistanceFieldConventions.PixelRangeSource

Returns

string

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

float?

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 Material

The 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 string

The distance field texture property.

Returns

string

IsVertexData(PixelRangeSource)

Is this source informed through vertex data or material property?

public static bool IsVertexData(this DistanceFieldConventions.PixelRangeSource self)

Parameters

self DistanceFieldConventions.PixelRangeSource

Returns

bool

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 Sprite
pixelRange int