API

The following section describes the exposed properties of the shader. You can use those properties to dynamically change various shader options from your own scripts.

_MainTex

The main (albedo/color) texture used by the shader, and the texture that the outline is traced from. A Sprite Renderer fills this in with its sprite automatically. See Main Texture for more information.

Usage

On a Sprite Renderer, Unity supplies this texture from the renderer's sprite and overrides any value set on the material. To change it, assign a new sprite instead. With spriteRenderer being the object's sprite renderer, and newSprite being the sprite you would like to apply to the object, set the value like so:
spriteRenderer.sprite = newSprite;
and read the texture like so:
Texture texture = spriteRenderer.sprite.texture;
On renderers without a sprite (e.g., a Mesh Renderer), with material being the material of the object's renderer, and newTexture being the main texture you would like to apply to the object, set the value like so:
material.SetTexture("_MainTex", newTexture);
and read it like so:
Texture texture = material.GetTexture("_MainTex");

_BaseColor

An additional color multiplied with the one already present in the main texture. Use this to further customize the look of your sprite. See Albedo for more information.

Usage

With material being the material of the object's sprite renderer, and newColor being the albedo color you would like to apply to the object, set the value like so:
material.SetColor("_BaseColor", newColor);
and read it like so:
Color color = material.GetColor("_BaseColor");

_Cutoff

This is a threshold value - all parts of the texture whose alpha value is less than the alpha cutoff will not be rendered. The outline is still traced from the full alpha of the texture. See Alpha Cutoff for more information.

Usage

With material being the material of the object's sprite renderer, and newCutoff being the cutoff value you would like to apply to the object, set the value like so:
material.SetFloat("_Cutoff", newCutoff);
and read it like so:
float cutoff = material.GetFloat("_Cutoff");

_AmbientOcclusion

The regular ambient occlusion from the standard URP Lit shader. See Ambient Occlusion for more information.
This property is not available in the 2D Renderer version of the shader.

Usage

With material being the material of the object's sprite renderer, and newAmbientOcclusion being the ambient occlusion value you would like to apply to the object, set the value like so:
material.SetFloat("_AmbientOcclusion", newAmbientOcclusion);
and read it like so:
float occlusion = material.GetFloat("_AmbientOcclusion");

_MetallicGlossMap

The standard metallic map option in the default URP Lit shader. The metallic map is a black-and-white texture that determines the surface type of the object. It is used to make certain parts of the sprite reflect light like a metal would (metallic), and others like sand would (smooth). See Metallic Map for more information.
This property is not available in the 2D Renderer version of the shader.

Usage

With material being the material of the object's sprite renderer, and newMap being the metallic map you would like to apply to the object, set the value like so:
material.SetTexture("_MetallicGlossMap", newMap);
and read it like so:
Texture metallicMap = material.GetTexture("_MetallicGlossMap");

_Metallic

This value determines how "metallic" the surface should be, i.e., whether it should reflect light like a metal or a wet surface, or should absorb it like sand or another rough, non-metallic surface. See Metallic for more information.
This property is not available in the 2D Renderer version of the shader.

Usage

With material being the material of the object's sprite renderer, and newMetallic being the metallic value you would like to apply to the object, set the value like so:
material.SetFloat("_Metallic", newMetallic);
and read it like so:
float metallic = material.GetFloat("_Metallic");

_BumpMap

The standard normal map option in the default URP Lit shader. The normal map is used to simulate a 3D-surface by containing information on how the light should be reflected by the surface. See Normal Map for more information.

Usage

With material being the material of the object's sprite renderer, and newMap being the normal map you would like to apply to the object, set the value like so:
material.SetTexture("_BumpMap", newMap);
and read it like so:
Texture normalMap = material.GetTexture("_BumpMap");

_BumpScale

This value is multiplied with the normal map and is used to make the effect stronger or weaker. A negative value will mirror the 3D-effect (i.e., protruding surfaces will now be concave, and vice versa). It starts at 0, which leaves the normal map without any effect. See Normal Strength for more information.

Usage

With material being the material of the object's sprite renderer, and newStrength being the normal strength value you would like to apply to the object, set the value like so:
material.SetFloat("_BumpScale", newStrength);
and read it like so:
float strength = material.GetFloat("_BumpScale");

_EmissionColor

The emission color as an HDR color. Keep in mind that different post-processing effects (most notably bloom) will have a profound effect on the look of your emission. See Emission Color for more information.

Usage

With material being the material of the object's sprite renderer, and newColor being the emission color you would like to apply to the object, set the value like so:
material.SetColor("_EmissionColor", newColor);
and read it like so:
Color color = material.GetColor("_EmissionColor");

_EmissionMap

The standard emission map option in the default URP Lit shader. A black-and-white map that determines which parts of the sprite will emit light. The white pixels of the texture are areas where the emission will have an effect, and the black pixels are the areas with no emission. See Emission Map for more information.

Usage

With material being the material of the object's sprite renderer, and newMap being the emission map you would like to apply to the object, set the value like so:
material.SetTexture("_EmissionMap", newMap);
and read it like so:
Texture emissionMap = material.GetTexture("_EmissionMap");

_EmissionExtraIntensity

Since the default HDR color has a limited intensity (-10 to 10), this shader offers an additional intensity option that allows you to make your emission even stronger. It starts at 0, where there is no visible emission, and it requires a perspective camera. See Emission Extra Intensity for more information.

Usage

With material being the material of the object's sprite renderer, and newIntensity being the emission intensity value you would like to apply to the object, set the value like so:
material.SetFloat("_EmissionExtraIntensity", newIntensity);
and read it like so:
float intensity = material.GetFloat("_EmissionExtraIntensity");

_OutlineWidth

The thickness of the outline, measured in texels of the main texture. The same value therefore looks thinner on a high-resolution sprite than on a low-resolution one, and the outline scales along with the sprite. See Outline Width for more information.

Usage

With material being the material of the object's sprite renderer, and newWidth being the outline width value you would like to apply to the object, set the value like so:
material.SetFloat("_OutlineWidth", newWidth);
and read it like so:
float width = material.GetFloat("_OutlineWidth");

_OutlineColor

The color of the outline as an HDR color. The outline is drawn as emission, so it is not affected by the lights in your scene, and a high intensity combined with bloom makes it glow. The alpha value controls the opacity of the outline - set it to 0 to hide the outline completely. See Outline Color for more information.

Usage

With material being the material of the object's sprite renderer, and newColor being the outline color you would like to apply to the object, set the value like so:
material.SetColor("_OutlineColor", newColor);
and read it like so:
Color color = material.GetColor("_OutlineColor");

_Outline_Softness

How gradually the outline fades out (0 to 5). At 0, the outline has a hard edge. At 1, it fades smoothly from full strength to nothing, which turns it into a glow. Values above 1 also make the outline fainter. See Outline Softness for more information.

Usage

With material being the material of the object's sprite renderer, and newSoftness being the outline softness value you would like to apply to the object, set the value like so:
material.SetFloat("_Outline_Softness", newSoftness);
and read it like so:
float softness = material.GetFloat("_Outline_Softness");

_QUALITY

The number of times the main texture is sampled per pixel to trace the outline: 8 on Low Quality, 16 on Medium Quality, and 32 on High Quality, which is the default. See Outline Quality for more information.

Usage

Outline Quality is a shader keyword rather than a regular property, so it works differently to other value types. It is set using the methods Material.EnableKeyword and Material.DisableKeyword, and its keywords are written in the format {KEYWORD NAME}_{ENUM VALUE}. Enable exactly one of _QUALITY_LOW_QUALITY, _QUALITY_MEDIUM_QUALITY, and _QUALITY_HIGH_QUALITY on the material, and disable the other two. With material being the material of the object's sprite renderer, switch to e.g. Low Quality like so:
material.EnableKeyword("_QUALITY_LOW_QUALITY");
material.DisableKeyword("_QUALITY_MEDIUM_QUALITY");
material.DisableKeyword("_QUALITY_HIGH_QUALITY");
and check the current quality like so:
bool isLowQuality = material.IsKeywordEnabled("_QUALITY_LOW_QUALITY");
Unity strips the keyword variants that no material uses from your build, so make sure that at least one material in the build uses the quality you switch to.

_Inner_Outline

Disabled by default, which draws the outline outside of the sprite. Enable this option to draw the outline inside of the sprite instead, starting from its edges and replacing the sprite's own color underneath. See Inner Outline for more information.

Usage

With material being the material of the object's sprite renderer, and value being the toggle value (1 for true, 0 for false) you would like to apply to the object, set the value like so:
material.SetFloat("_Inner_Outline", value);
and read it like so:
float innerOutline = material.GetFloat("_Inner_Outline");

_MainTex _BaseColor _Cutoff _AmbientOcclusion _MetallicGlossMap _Metallic _BumpMap _BumpScale _EmissionColor _EmissionMap _EmissionExtraIntensity _OutlineWidth _OutlineColor _Outline_Softness _QUALITY _Inner_Outline