56 lines
1.2 KiB
Plaintext
56 lines
1.2 KiB
Plaintext
Shader "Custom/Outline" {
|
|
Properties {
|
|
_OutlineColor ("Outline Color", Color) = (1, 0.5, 0, 1)
|
|
_Outline ("Outline width", Range (0, 1)) = 0.02
|
|
}
|
|
|
|
CGINCLUDE
|
|
#include "UnityCG.cginc"
|
|
|
|
struct appdata {
|
|
float4 vertex : POSITION;
|
|
float3 normal : NORMAL;
|
|
};
|
|
|
|
struct v2f {
|
|
float4 pos : POSITION;
|
|
float4 color : COLOR;
|
|
};
|
|
|
|
uniform float _Outline;
|
|
uniform float4 _OutlineColor;
|
|
|
|
v2f vert(appdata v) {
|
|
v2f o;
|
|
|
|
// Scale the vertex position based on the outline width
|
|
o.pos = UnityObjectToClipPos(v.vertex * (1 + _Outline));
|
|
o.color = _OutlineColor;
|
|
|
|
return o;
|
|
}
|
|
ENDCG
|
|
|
|
SubShader {
|
|
Tags { "DisableBatching" = "True" }
|
|
Pass {
|
|
Name "OUTLINE"
|
|
Tags { "LightMode" = "Always" }
|
|
Cull Front
|
|
ZWrite On
|
|
ColorMask RGB
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
half4 frag(v2f i) : COLOR {
|
|
return i.color;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
|
|
Fallback "Diffuse"
|
|
}
|