Skip to content

Instantly share code, notes, and snippets.

@BeautyfullCastle
Created February 25, 2019 06:08
Show Gist options
  • Save BeautyfullCastle/99609a00c3337e6233456fbc65632be6 to your computer and use it in GitHub Desktop.
Save BeautyfullCastle/99609a00c3337e6233456fbc65632be6 to your computer and use it in GitHub Desktop.
Unlit transparent shader with alpha property.
Shader "Unlit/Transparent Alpha" {
Properties{
_Alpha("Alpha", Range(0.0, 1.0)) = 1.0
_MainTex("Texture", 2D) = "white" {}
}
SubShader{
Tags {"Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent"}
LOD 100
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _Alpha;
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) * _Alpha;
return col;
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment