Skip to content

Instantly share code, notes, and snippets.

@jasursadikov
Created July 31, 2021 10:53
Show Gist options
  • Save jasursadikov/44c122c7e48c7eb194e4b185fbea01ab to your computer and use it in GitHub Desktop.
Save jasursadikov/44c122c7e48c7eb194e4b185fbea01ab to your computer and use it in GitHub Desktop.
Simple unlit burn effect unity shader
Shader "Unlit/Dissolve Cutout"
{
Properties
{
_Color ("Color", Color) = (1, 1, 1, 1)
_MainTex ("Base (RGB)", 2D) = "white" { }
_Dissolve ("Dissolve (A)", 2D) = "white" { }
_EdgeColor ("Edge Color", Color) = (1, 1, 1, 1)
_EdgeSize ("Edge Size", Range(0, 1)) = 0.5
}
SubShader
{
Tags { "Queue" = "AlphaTest" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout" }
LOD 100
Lighting Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex: POSITION;
float2 texcoord: TEXCOORD0;
};
struct v2f
{
float4 vertex: SV_POSITION;
float2 texcoord: TEXCOORD0;
};
float4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;
sampler2D _Dissolve;
fixed _EdgeSize;
float4 _EdgeColor;
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
fixed4 frag(v2f i): SV_Target
{
fixed4 col = tex2D(_MainTex, i.texcoord) * _Color;
half cutoff = 1 - _Color.a;
half dissolve = tex2D(_Dissolve, i.texcoord).rgb - cutoff;
if (col.a < 0.1)
{
clip(col.a - 0.1);
}
else
{
clip(dissolve);
}
if(dissolve < _EdgeSize && cutoff > 0)
{
col.rgb = _EdgeColor;
}
col.a = dissolve;
return col;
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment