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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
// Unlit alpha-blended shader.
// - no lighting
// - no lightmap support
// - no per-material color
Shader "ASESampleShaders/RimLight" {
Properties{
_MainTex("Base (RGBA)", 2D) = "white" {}
[HDR]_Color1("Hi Color", color) = (1.0,1.0,1.0,1.0)
_Step1("Color Cutoff", range(0.0,2.0)) = 0.5
[HDR]_Color2("Lo Color", color) = (1.0,0.95,0.8,1.0)
_Intensity("Intensity", range(1,0)) = 1
_MKGlowPower("Emission Power", range(0,10)) = 0
_MKGlowColor("Emission Color", color) = (1.0,0.95,0.8,1.0)
_StencilMask("Mask Layer", Range(0, 255)) = 1
[Enum(CompareFunction)] _StencilComp("Mask Mode", Int) = 6
_Albedo("Albedo", 2D) = "white" {}
_CutOff("Alpha CutOff", Float) = 0.5
_NoiseMap("Noise Map", 2D) = "white"{}
}
SubShader{
Tags{ "Queue" = "AlphaTest-1" "IgnoreProjector" = "False" "RenderType" = "Transparent" "RenderType" = "MKGlow" }
Stencil
{
Ref 255
ReadMask[_StencilMask]
Comp[_StencilComp]
}
//Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "RenderType" = "MKGlow" }
LOD 100
//ZWrite Off
Blend One OneMinusSrcAlpha//SrcAlpha OneMinusSrcAlpha
//AlphaToMask On
Pass{
Cull Front
ZTest LEqual
ZWrite Off
Blend One OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
float2 maskcoord : TEXCOORD1;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
half2 maskcoord : TEXCOORD1;
half2 norisecoord : TEXCOORD2;
//fixed4 color : COLOR;
};
//sampler2D _MainTex;
float4 _MainTex_ST;
float4 _Color1;
float4 _Color2;
float _Step1;
float _Intensity;
sampler2D _Albedo;
float4 _Albedo_ST;
sampler2D _NoiseMap;
float4 _NoiseMap_ST;
float _CutOff;
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _Albedo);
o.color = v.color;
o.norisecoord = TRANSFORM_TEX(v.texcoord, _NoiseMap);
return o;
}
sampler2D _MainTex;
fixed4 frag(v2f i) : SV_Target
{
float alpha = tex2D(_Albedo, i.texcoord).a;
if(alpha <= _CutOff)
discard;
fixed4 col = tex2D(_Albedo, i.texcoord);
fixed norise = tex2D(_NoiseMap, i.norisecoord).r;
if (norise > _Intensity)
discard;
float blendV = col.r;
float texA = col.a;
//col = lerp(_Color2,_Color1,smoothstep(0,_Step1,blendV));
col = lerp(_Color2,_Color1, _Intensity);
//col *= _Intensity;
//col.xyz *= texA;
//col.a *= texA;
//col *= i.color;
//return fixed4(col.r, col.g, col.b, col.a);
return col;
}
ENDCG
}
}
}
|