文档

Unity Engine


User Manual

Script Reference

Unity Engine


Sprite Lit shader graph reference for URP

Explore the properties and settings of the default shader graph for lit 2D sprites.
阅读时间3 分钟最后更新于 1 个月前

Explore the properties and settings you can use to customize the default Sprite Lit shader graph in the Universal Render Pipeline (URP).
For more information about 2D shaders in URP, refer to 2D Lighting in URP.

Contexts

The default Vertex and Fragment Contexts contain the following Blocks. Which Blocks display might change depending on the graph settings.

Vertex Context

The default values are the values from the mesh.

Input

Type

Description

PositionVector3Sets the vertex position in object space.
NormalVector3Sets the normal of the vertex in object space.
TangentVector3Sets the tangent of the vertex in object space.

Fragment Context

Input

Type

Description

Base ColorVector3Sets the base color of the material. The default is
Color.grey
.
Sprite MaskVector4Sets a custom mask that determines whether the pixels of the sprite are visible. For more information, refer to Add normal map and mask textures to a sprite.
Normal (Tangent Space)Vector3Sets a custom normal map to simulate bumps and grooves on the surface of the sprite. For more information, refer to Add normal map and mask textures to a sprite.
AlphaFloatSets the alpha of the material. The range is 0 to 1. The default is 1.
Alpha Clip ThresholdFloatSets the minimum alpha value for a pixel to be visible. The range is 0 to 1. The default is 0.5. This property is only available if you enable Alpha Clipping in the graph settings.

Graph Settings

Explore the shader graph settings you can use to customize the Fragment and Vertex contexts.
For more details about graph settings that are common to all shader graph shaders, refer to Graph Settings tab.

Setting

Description

Blending ModeSets how the shader blends the color of a transparent material with the background. The options are:
  • Alpha: Calculates transparency using the alpha value of the material.
  • Premultiply: Calculates transparency using the alpha value of the material, but multiplies the RGB values by the alpha value first.
  • Additive: Adds the color of the material to the background color.
  • Multiply: Multiplies the color of the material with the background color.
For more information about blending modes, refer to Blend modes.
Depth WriteDetermines whether the shader writes depth information to the depth buffer. The options are:
  • Auto: Sets opaque objects to write to the depth buffer, and transparent objects to not write to the depth buffer.
  • Force Enabled: Enables all objects from writing to the depth buffer.
  • Force Disabled: Disables all objects from writing to the depth buffer.
Alpha ClippingDiscards pixels if their alpha value is lower than a threshold value. Enabling this setting adds the Alpha Clip Threshold Block to the Fragment context.
Disable Color TintPrevents Shader Graph tinting the sprite with the Color property of the sprite. If you enable this setting, use a Vertex Color Node to access the Color property of the sprite.
Sort 3D as 2D CompatibleUses 2D sorting rules to draw 3D objects, to avoid 2D objects appearing at the wrong depth.
Custom Editor GUIRenders a custom editor GUI in the Inspector window of the material. Enter the name of the GUI class in the field. For more information, refer to Control material properties in the Inspector window.

Additional resources