|
@@ -3,7 +3,7 @@
|
|
|
Properties
|
|
|
{
|
|
|
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
|
|
|
- _Color("Tint", Color) = (1,1,1,1)
|
|
|
+ _Scale("Scale", float) = 0.02
|
|
|
[MaterialToggle] PixelSnap("Pixel snap", Float) = 0
|
|
|
}
|
|
|
|
|
@@ -27,59 +27,6 @@
|
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
|
|
|
|
CGPROGRAM
|
|
|
-
|
|
|
- #pragma vertex vert
|
|
|
- #pragma fragment frag
|
|
|
-
|
|
|
- #include "UnityCG.cginc"
|
|
|
-
|
|
|
- struct appdata_t
|
|
|
- {
|
|
|
- float4 vertex : POSITION;
|
|
|
- float2 texcoord : TEXCOORD0;
|
|
|
- };
|
|
|
-
|
|
|
- struct v2f
|
|
|
- {
|
|
|
- float4 vertex : SV_POSITION;
|
|
|
- float2 texcoord : TEXCOORD0;
|
|
|
- };
|
|
|
-
|
|
|
- v2f vert(appdata_t IN)
|
|
|
- {
|
|
|
- v2f OUT;
|
|
|
-
|
|
|
- OUT.vertex = UnityObjectToClipPos(IN.vertex * 1.1);
|
|
|
- OUT.texcoord = IN.texcoord;
|
|
|
-
|
|
|
- return OUT;
|
|
|
- }
|
|
|
-
|
|
|
- sampler2D _MainTex;
|
|
|
-
|
|
|
- fixed4 SampleSpriteTexture(float2 uv)
|
|
|
- {
|
|
|
- fixed4 color = tex2D(_MainTex, uv);
|
|
|
-
|
|
|
- return color;
|
|
|
- }
|
|
|
-
|
|
|
- fixed4 frag(v2f IN) : SV_Target
|
|
|
- {
|
|
|
- fixed4 c = SampleSpriteTexture(IN.texcoord);
|
|
|
-
|
|
|
- c.rgb = 1;
|
|
|
-
|
|
|
- return c;
|
|
|
- }
|
|
|
- ENDCG
|
|
|
- }
|
|
|
-
|
|
|
- Pass
|
|
|
- {
|
|
|
- Blend SrcAlpha OneMinusSrcAlpha
|
|
|
-
|
|
|
- CGPROGRAM
|
|
|
|
|
|
#pragma vertex vert
|
|
|
#pragma fragment frag
|
|
@@ -96,54 +43,60 @@
|
|
|
float4 vertex : POSITION;
|
|
|
float4 color : COLOR;
|
|
|
float2 texcoord : TEXCOORD0;
|
|
|
- UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
|
};
|
|
|
|
|
|
struct v2f
|
|
|
{
|
|
|
float4 vertex : SV_POSITION;
|
|
|
- fixed4 color : COLOR;
|
|
|
float2 texcoord : TEXCOORD0;
|
|
|
- UNITY_VERTEX_OUTPUT_STEREO
|
|
|
};
|
|
|
|
|
|
- fixed4 _Color;
|
|
|
+ float _Scale;
|
|
|
|
|
|
v2f vert(appdata_t IN)
|
|
|
{
|
|
|
v2f OUT;
|
|
|
- UNITY_SETUP_INSTANCE_ID(IN);
|
|
|
- UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
|
|
+
|
|
|
OUT.vertex = UnityObjectToClipPos(IN.vertex);
|
|
|
OUT.texcoord = IN.texcoord;
|
|
|
- OUT.color = IN.color * _Color;
|
|
|
- #ifdef PIXELSNAP_ON
|
|
|
- OUT.vertex = UnityPixelSnap(OUT.vertex);
|
|
|
- #endif
|
|
|
|
|
|
return OUT;
|
|
|
}
|
|
|
|
|
|
sampler2D _MainTex;
|
|
|
- sampler2D _AlphaTex;
|
|
|
|
|
|
fixed4 SampleSpriteTexture(float2 uv)
|
|
|
{
|
|
|
fixed4 color = tex2D(_MainTex, uv);
|
|
|
|
|
|
- #if ETC1_EXTERNAL_ALPHA
|
|
|
- // get the color from an external texture (usecase: Alpha support for ETC1 on android)
|
|
|
- color.a = tex2D(_AlphaTex, uv).r;
|
|
|
- #endif //ETC1_EXTERNAL_ALPHA
|
|
|
-
|
|
|
return color;
|
|
|
}
|
|
|
|
|
|
fixed4 frag(v2f IN) : SV_Target
|
|
|
{
|
|
|
- fixed4 c = SampleSpriteTexture(IN.texcoord) * IN.color;
|
|
|
- c.rgb *= c.a;
|
|
|
-
|
|
|
+ fixed4 c = SampleSpriteTexture(IN.texcoord);
|
|
|
+
|
|
|
+ if (c.a == 0)
|
|
|
+ {
|
|
|
+ fixed4 c1 = SampleSpriteTexture(IN.texcoord + float2(_Scale, 0));
|
|
|
+ fixed4 c2 = SampleSpriteTexture(IN.texcoord + float2(-_Scale, 0));
|
|
|
+ fixed4 c3 = SampleSpriteTexture(IN.texcoord + float2(0, _Scale));
|
|
|
+ fixed4 c4 = SampleSpriteTexture(IN.texcoord + float2(0, -_Scale));
|
|
|
+ fixed4 c5 = SampleSpriteTexture(IN.texcoord + float2(_Scale, _Scale));
|
|
|
+ fixed4 c6 = SampleSpriteTexture(IN.texcoord + float2(_Scale, -_Scale));
|
|
|
+ fixed4 c7 = SampleSpriteTexture(IN.texcoord + float2(-_Scale, _Scale));
|
|
|
+ fixed4 c8 = SampleSpriteTexture(IN.texcoord + float2(-_Scale, -_Scale));
|
|
|
+
|
|
|
+ if (c1.a > 0 || c2.a > 0 || c3.a > 0 || c4.a > 0 || c5.a > 0 || c6.a > 0 || c7.a > 0 || c8.a > 0)
|
|
|
+ {
|
|
|
+ c.rgba = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (c.a < 1)
|
|
|
+ {
|
|
|
+ c.rgba = 1;
|
|
|
+ }
|
|
|
+
|
|
|
return c;
|
|
|
}
|
|
|
ENDCG
|