lcy
2025-01-02 c867ea92cce28ea0ceb312ef8e2f8e7e0888b1d6
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
Shader "Effect/Edge_Dissolve"
{
    Properties
    {
        _MainTex ("Diffuse", 2D) = "white" { }
        _Noise ("Noise", 2D) = "white" { }
        _edge ("勾边大小", Float) = 0.1
        _brightness ("勾边亮度", Float) = 100
        _diffuseStrength ("diffuse强度", Float) = 10
        _color ("color", Color) = (0.8, 0.3, 0.1, 1)
    }
 
    SubShader
    {
        Tags { "IgnoreProjector" = "True" "Queue" = "Transparent" "RenderType" = "Transparent" }
 
        Pass
        {
            Tags { "LightMode" = "ForwardBase" }
 
            Blend SrcAlpha OneMinusSrcAlpha
            Cull Off
            ZWrite Off
            
            CGPROGRAM
            
            #pragma vertex vert
            #pragma fragment frag
            //#define UNITY_PASS_FORWARDBASE
            #include "UnityCG.cginc"
            #pragma multi_compile_fwdbase
            #pragma exclude_renderers xbox360 ps3 flash
            #pragma target 3.0
 
            uniform sampler2D _MainTex;
            uniform sampler2D _Noise;
            uniform float _edge;
            uniform float _brightness;
            uniform float _diffuseStrength;
            uniform float4 _color;
 
            struct VertexInput
            {
                float4 vertex: POSITION;
                float3 normal: NORMAL;
                float4 tangent: TANGENT;
                float2 texcoord0: TEXCOORD0;
                float4 vertexColor: COLOR;
            };
 
            struct VertexOutput
            {
                float4 pos: SV_POSITION;
                float2 uv0: TEXCOORD0;
                float4 vertexColor: COLOR;
            };
 
            VertexOutput vert(VertexInput v)
            {
                VertexOutput o = (VertexOutput)0;
                o.uv0 = v.texcoord0;
                o.vertexColor = v.vertexColor;
                o.pos = UnityObjectToClipPos(v.vertex);
 
                return o;
            }
 
            fixed4 frag(VertexOutput i): COLOR
            {
 
                fixed4 _DiffuseColor = tex2D(_MainTex, i.uv0);
                fixed4 _NoiseColor = tex2D(_Noise, i.uv0);
                fixed3 finalColor = (_diffuseStrength * (_color.rgb * _DiffuseColor.rgb)) * _DiffuseColor.r;
 
                fixed edgeA = step(_NoiseColor.r, (_edge + i.vertexColor.r));
                fixed edgeB = step(_NoiseColor.r, i.vertexColor.r);
 
                return fixed4(finalColor * (1 + (i.vertexColor.a * _DiffuseColor.a * (edgeA - edgeB) * _brightness)), i.vertexColor.a * _DiffuseColor.a);
            }
            ENDCG
            
        }
    }
    // FallBack "Additive"
}