Alpha Shader adding feathered edge

Hello all! I’m trying to create a shader that when I add a mask texture I can have a float property such as my _Glow that controls a feather’d effect. The current masks are supposed to highlight the edges of my objects and I’d like add a feather that grows inward (in addition to the mask texture) from the edges/mask texture.

It’s hard for me to explain exactly but instead of subtracting from the mask id like to add as if adding pixels to a mask in photoshop and feathering the edge. Almost as if the the edges have an emission value within the texture itself. I’m assuming there is a math function I need to add to this shader, but I can’t seem to find a list of possible functions with their definitions and usages anywhere with out searching each one individually.

Here’s My code so far:

Properties {
_OverlayTex ("Overlay (RGBA)", 2D) = "" {}
_Color ("Color", Color) = (0,0,0,1)
_ELevel("Glow Strength", Range(0.01,10.0)) = 1.0
_Glow ("Glow Amount", Range(.05,1)) = 1

}
SubShader {
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha:fade
#pragma target 3.0

#include "UnityStandardUtils.cginc"

sampler2D _OverlayTex;
fixed4 _Color;
float _ELevel;
half base = (1,1,1,1);
float _Glow;

struct Input {
float2 uv2_OverlayTex;
float4 _Color;
float _ELevel;
half base;
float _Glow;

};

void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_OverlayTex, IN.uv2_OverlayTex) * _Color;
float4 g = lerp(1,base, _Glow);
o.Albedo = c* _Color;
o.Alpha = saturate(c.a+ g);
o.Emission = _Color* _ELevel;
}
ENDCG
}
FallBack "Diffuse"
}


A blur, which is what you’re really looking for, isn’t as simple as a bit of math or a single function call, and it can be expensive. The easiest solution is to put the glow into your existing overlay texture.

I don’t know exactly what your texture looks like, but presumably it’s a solid white with an alpha and you’re using the _Color value to actually set the line color? If so you can pack other data into the RGB channels, like a blurred version of your outline. You can then fade this in on top of your outline, or just some simple math (multiply and add or subtract) to adjust the size and intensity of the glow.