187 lines
6.0 KiB
Plaintext
187 lines
6.0 KiB
Plaintext
Shader "Universal Render Pipeline/2D/Sprite-Lit-Default"
|
|
{
|
|
Properties
|
|
{
|
|
_MainTex("Diffuse", 2D) = "white" {}
|
|
_MaskTex("Mask", 2D) = "white" {}
|
|
_NormalMap("Normal Map", 2D) = "bump" {}
|
|
[MaterialToggle] _ZWrite("ZWrite", Float) = 0
|
|
|
|
// Legacy properties. They're here so that materials using this shader can gracefully fallback to the legacy sprite shader.
|
|
[HideInInspector] _Color("Tint", Color) = (1,1,1,1)
|
|
[HideInInspector] _RendererColor("RendererColor", Color) = (1,1,1,1)
|
|
[HideInInspector] _AlphaTex("External Alpha", 2D) = "white" {}
|
|
[HideInInspector] _EnableExternalAlpha("Enable External Alpha", Float) = 0
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags {"Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }
|
|
|
|
Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
|
|
Cull Off
|
|
ZWrite [_ZWrite]
|
|
|
|
Pass
|
|
{
|
|
Tags { "LightMode" = "Universal2D" }
|
|
|
|
HLSLPROGRAM
|
|
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl"
|
|
|
|
#pragma vertex LitVertex
|
|
#pragma fragment LitFragment
|
|
|
|
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/ShapeLightShared.hlsl"
|
|
|
|
// GPU Instancing
|
|
#pragma multi_compile_instancing
|
|
#pragma multi_compile _ DEBUG_DISPLAY
|
|
#pragma multi_compile _ SKINNED_SPRITE
|
|
|
|
struct Attributes
|
|
{
|
|
COMMON_2D_INPUTS
|
|
half4 color : COLOR;
|
|
UNITY_SKINNED_VERTEX_INPUTS
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
COMMON_2D_LIT_OUTPUTS
|
|
half4 color : COLOR;
|
|
};
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Lit2DCommon.hlsl"
|
|
|
|
// NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
|
|
CBUFFER_START(UnityPerMaterial)
|
|
half4 _Color;
|
|
CBUFFER_END
|
|
|
|
Varyings LitVertex(Attributes input)
|
|
{
|
|
UNITY_SKINNED_VERTEX_COMPUTE(input);
|
|
SetUpSpriteInstanceProperties();
|
|
input.positionOS = UnityFlipSprite(input.positionOS, unity_SpriteProps.xy);
|
|
|
|
Varyings o = CommonLitVertex(input);
|
|
o.color = input.color * _Color * unity_SpriteColor;
|
|
|
|
return o;
|
|
}
|
|
|
|
half4 LitFragment(Varyings input) : SV_Target
|
|
{
|
|
return CommonLitFragment(input, input.color);
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
Pass
|
|
{
|
|
Tags { "LightMode" = "NormalsRendering"}
|
|
|
|
HLSLPROGRAM
|
|
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl"
|
|
|
|
#pragma vertex NormalsRenderingVertex
|
|
#pragma fragment NormalsRenderingFragment
|
|
|
|
// GPU Instancing
|
|
#pragma multi_compile_instancing
|
|
#pragma multi_compile _ SKINNED_SPRITE
|
|
|
|
struct Attributes
|
|
{
|
|
COMMON_2D_NORMALS_INPUTS
|
|
float4 color : COLOR;
|
|
UNITY_SKINNED_VERTEX_INPUTS
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
COMMON_2D_NORMALS_OUTPUTS
|
|
half4 color : COLOR;
|
|
};
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Normals2DCommon.hlsl"
|
|
|
|
// NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
|
|
CBUFFER_START( UnityPerMaterial )
|
|
half4 _Color;
|
|
CBUFFER_END
|
|
|
|
Varyings NormalsRenderingVertex(Attributes input)
|
|
{
|
|
UNITY_SKINNED_VERTEX_COMPUTE(input);
|
|
SetUpSpriteInstanceProperties();
|
|
input.positionOS = UnityFlipSprite(input.positionOS, unity_SpriteProps.xy);
|
|
|
|
Varyings o = CommonNormalsVertex(input);
|
|
o.color = input.color * _Color * unity_SpriteColor;
|
|
|
|
return o;
|
|
}
|
|
|
|
half4 NormalsRenderingFragment(Varyings input) : SV_Target
|
|
{
|
|
return CommonNormalsFragment(input, input.color);
|
|
}
|
|
ENDHLSL
|
|
}
|
|
|
|
Pass
|
|
{
|
|
Tags { "LightMode" = "UniversalForward" "Queue"="Transparent" "RenderType"="Transparent"}
|
|
|
|
HLSLPROGRAM
|
|
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl"
|
|
|
|
#pragma vertex UnlitVertex
|
|
#pragma fragment UnlitFragment
|
|
|
|
struct Attributes
|
|
{
|
|
COMMON_2D_INPUTS
|
|
half4 color : COLOR;
|
|
UNITY_SKINNED_VERTEX_INPUTS
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
COMMON_2D_OUTPUTS
|
|
half4 color : COLOR;
|
|
};
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/2DCommon.hlsl"
|
|
|
|
// GPU Instancing
|
|
#pragma multi_compile_instancing
|
|
#pragma multi_compile _ DEBUG_DISPLAY SKINNED_SPRITE
|
|
|
|
// NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
|
|
CBUFFER_START(UnityPerMaterial)
|
|
half4 _Color;
|
|
CBUFFER_END
|
|
|
|
Varyings UnlitVertex(Attributes input)
|
|
{
|
|
UNITY_SKINNED_VERTEX_COMPUTE(input);
|
|
SetUpSpriteInstanceProperties();
|
|
input.positionOS = UnityFlipSprite(input.positionOS, unity_SpriteProps.xy);
|
|
|
|
Varyings o = CommonUnlitVertex(input);
|
|
o.color = input.color *_Color * unity_SpriteColor;
|
|
return o;
|
|
}
|
|
|
|
half4 UnlitFragment(Varyings input) : SV_Target
|
|
{
|
|
return CommonUnlitFragment(input, input.color);
|
|
}
|
|
ENDHLSL
|
|
}
|
|
}
|
|
}
|