三国卡牌客户端基础资源仓库
yyl
2025-05-07 28c068825ca4ed2b7017204d1fb3d613467db7cb
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
#ifndef SPRITES_DEPTH_ONLY_PASS_INCLUDED
#define SPRITES_DEPTH_ONLY_PASS_INCLUDED
 
#include "UnityCG.cginc"
 
sampler2D _MainTex;
float _Cutoff;
float _ZWriteOffset;
 
struct VertexInput {
    float4 positionOS : POSITION;
    float2 texcoord : TEXCOORD0;
    float4 vertexColor : COLOR;
};
 
struct VertexOutput {
    float4 positionCS : SV_POSITION;
    float4 texcoordAndAlpha: TEXCOORD0;
};
 
VertexOutput DepthOnlyVertex (VertexInput v) {
    VertexOutput o;
    o.positionCS = UnityObjectToClipPos(v.positionOS - float4(0, 0, _ZWriteOffset, 0));
    o.texcoordAndAlpha.xy = v.texcoord;
    o.texcoordAndAlpha.z = 0;
    o.texcoordAndAlpha.a = v.vertexColor.a;
    return o;
}
 
float4 DepthOnlyFragment (VertexOutput input) : SV_Target{
    float4 texColor = tex2D(_MainTex, input.texcoordAndAlpha.rg);
 
    #if defined(_STRAIGHT_ALPHA_INPUT)
    texColor.rgb *= texColor.a;
    #endif
 
    clip(texColor.a * input.texcoordAndAlpha.a - _Cutoff);
    return 0;
}
 
#endif