三国卡牌客户端基础资源仓库
hch
2025-09-12 a0935e244cf12d62f33d4fadd04df716c60e7ae6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef SKELETON_GRAPHIC_NORMALPASS_INCLUDED
#define SKELETON_GRAPHIC_NORMALPASS_INCLUDED
 
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#include "../../CGIncludes/Spine-Common.cginc"
 
#pragma multi_compile __ UNITY_UI_ALPHACLIP
 
struct VertexInput {
    float4 vertex   : POSITION;
    float4 color    : COLOR;
    float2 texcoord : TEXCOORD0;
    UNITY_VERTEX_INPUT_INSTANCE_ID
};
 
struct VertexOutput {
    float4 vertex   : SV_POSITION;
    fixed4 color    : COLOR;
    half2 texcoord  : TEXCOORD0;
    float4 worldPosition : TEXCOORD1;
    UNITY_VERTEX_OUTPUT_STEREO
};
 
#ifndef ENABLE_GRAYSCALE
fixed4 _Color;
#endif
fixed4 _TextureSampleAdd;
float4 _ClipRect;
 
#ifdef ENABLE_FILL
float4 _FillColor;
float _FillPhase;
#endif
#ifdef ENABLE_GRAYSCALE
float _GrayPhase;
#endif
 
VertexOutput vert (VertexInput IN) {
    VertexOutput OUT;
 
    UNITY_SETUP_INSTANCE_ID(IN);
    UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
 
    OUT.worldPosition = IN.vertex;
    OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
    OUT.texcoord = IN.texcoord;
 
    #ifdef UNITY_HALF_TEXEL_OFFSET
    OUT.vertex.xy += (_ScreenParams.zw-1.0) * float2(-1,1);
    #endif
 
#ifdef _CANVAS_GROUP_COMPATIBLE
    half4 vertexColor = IN.color;
    // CanvasGroup alpha sets vertex color alpha, but does not premultiply it to rgb components.
    vertexColor.rgb *= vertexColor.a;
    // Unfortunately we cannot perform the TargetToGamma and PMAGammaToTarget transformations,
    // as these would be wrong with modified alpha.
#else
    // Note: CanvasRenderer performs a GammaToTargetSpace conversion on vertex color already,
    // however incorrectly assuming straight alpha color.
    // Saturated version used to prevent numerical issues of certain low-alpha values.
    float4 vertexColor = PMAGammaToTargetSpaceSaturated(half4(TargetToGammaSpace(IN.color.rgb), IN.color.a));
#endif
    OUT.color = vertexColor;
#ifndef ENABLE_GRAYSCALE
    OUT.color *= float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
#endif
 
    return OUT;
}
 
sampler2D _MainTex;
 
fixed4 frag (VertexOutput IN) : SV_Target
{
    half4 texColor = tex2D(_MainTex, IN.texcoord);
 
    #if defined(_STRAIGHT_ALPHA_INPUT)
    texColor.rgb *= texColor.a;
    #endif
 
    half4 color = (texColor + _TextureSampleAdd) * IN.color;
    color *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
 
    #ifdef UNITY_UI_ALPHACLIP
    clip (color.a - 0.001);
    #endif
 
    #ifdef ENABLE_FILL
    color.rgb = lerp(color.rgb, (_FillColor.rgb * color.a), _FillPhase); // make sure to PMA _FillColor.
    #endif
    #ifdef ENABLE_GRAYSCALE
    color.rgb = lerp(color.rgb, dot(color.rgb, float3(0.3, 0.59, 0.11)), _GrayPhase);
    #endif
    return color;
}
 
#endif