hello there, i hope someone would be very kind and help me out here.
i have created this outline shader and i am trying to figure out how to make an softer blend from one color to the outline color.
below you can see my current shader and another pic of what i am trying to achieve ![]()
thanks guys ![]()
this is my current outline
this is the look i am trying to get
and here is my shader:
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
// Upgrade NOTE: replaced '_Projector' with 'unity_Projector'
// Upgrade NOTE: replaced '_ProjectorClip' with 'unity_ProjectorClip'
Shader "Projector/Outline" {
Properties {
_ShadowTex ("Cookie", 2D) = "gray" {}
_FalloffTex ("FallOff", 2D) = "white" {}
// _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
_Color ("Main color", color) = (1,1,1,1)
_Stroke ("Stroke Alpha",range(0,1)) = 0.1
_Strokecolor ("Stroke Color",color) = (1,1,1,1)
}
Subshader {
Tags {"Queue"="Transparent"}
Pass {
ZWrite Off
ColorMask RGB
Blend DstColor Zero
Offset -1, -1
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct v2f {
float4 uvShadow : TEXCOORD0;
float4 uvFalloff : TEXCOORD1;
UNITY_FOG_COORDS(2)
float4 pos : SV_POSITION;
};
float4x4 unity_Projector;
float4x4 unity_ProjectorClip;
v2f vert (float4 vertex : POSITION)
{
v2f o;
o.pos = UnityObjectToClipPos (vertex);
o.uvShadow = mul (unity_Projector, vertex);
o.uvFalloff = mul (unity_ProjectorClip, vertex);
UNITY_TRANSFER_FOG(o,o.pos);
return o;
}
sampler2D _ShadowTex;
sampler2D _FalloffTex;
sampler2D _MainTex;
float4 _MainTex_ST;
fixed _Cutoff;
half4 _Color;
fixed _Stroke;
half4 _Strokecolor;
fixed4 frag (v2f i) : SV_Target
{
fixed4 texS = tex2Dproj (_ShadowTex, UNITY_PROJ_COORD(i.uvShadow));
texS.a = 1.0-texS.a;
fixed4 texF = tex2Dproj (_FalloffTex, UNITY_PROJ_COORD(i.uvFalloff));
fixed4 res = lerp(fixed4(1,1,1,0), texS, texF.a);
clip(res.a - _Cutoff);
UNITY_APPLY_FOG_COLOR(i.fogCoord, res, res.a);
if(res.a < _Stroke)
{
res = _Strokecolor;
res.a = _Strokecolor.a;
}
else
{
res = _Color;
res.a = _Color;
}
fixed4 comb = lerp(_Strokecolor, _Color, fixed4(1,1,1,1));
fixed4 res2 = (comb + res ) * fixed4 (1,1,1,1);
return res2;
}
ENDCG
}
}
}



