I got this shader from somewhere which i forgot, the default is only use solid color for the effect being hit. so i try to modified it to make it support shield texture as well.
Shader "TFTM/FX/Shield2" {
Properties {
_Position ("Collision", Vector) = (-1, -1, -1, -1)
_MaxDistance ("Effect Size", float) = 40
_ShieldColor ("Color (RGBA)", Color) = (0.7, 1, 1, 0)
_EmissionColor ("Emission color (RGBA)", Color) = (0.7, 1, 1, 0.01)
_EffectTime ("Effect Time (ms)", float) = 0
_MainTex ("Texture (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" }
LOD 2000
Cull Off
CGPROGRAM
#pragma surface surf Lambert vertex:vert alpha
#pragma target 3.0
struct Input {
float customDist;
float2 uv_MainTex;
};
sampler2D _MainTex;
float4 _Position;
float _MaxDistance;
float4 _ShieldColor;
float4 _EmissionColor;
float _EffectTime;
float _Amount;
void vert (inout appdata_full v, out Input o) {
o.customDist = distance(_Position.xyz, v.vertex.xyz);
o.uv_MainTex = v.texcoord;
}
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;//_ShieldColor.rgb;
o.Emission = _EmissionColor;
if(_EffectTime > 0)
{
if(IN.customDist < _MaxDistance){
o.Alpha = _EffectTime/500 - (IN.customDist / _MaxDistance) + _ShieldColor.a;
if(o.Alpha < _ShieldColor.a){
o.Alpha = _ShieldColor.a;
}
}
else {
o.Alpha = _ShieldColor.a;
}
}
else{
o.Alpha = o.Alpha = _ShieldColor.a;
}
}
ENDCG
}
Fallback "Transparent/Diffuse"
}
I replace color with texture here
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;//_ShieldColor.rgb;
but it is not working, it appear as one single color instead of texture around it.


The problem is with
o.Aplha. In the shader you published,surfreturns Alpha regardless of texture, so you need to changesurfmethod to set output Alpha based on texture.It can be done this way:
1) Replace
with
2) Insert
after
Result looks smth like this:
Complete result shader code: