Skip to content

Instantly share code, notes, and snippets.

@TocaLucas
Created September 26, 2013 13:12
Show Gist options
  • Save TocaLucas/6713975 to your computer and use it in GitHub Desktop.
Save TocaLucas/6713975 to your computer and use it in GitHub Desktop.
Shader "Custom/Frost" {
Properties {
_MainTex ("Frost Map (RGB)", 2D) = "white" {}
_FrostColor ("Frost Color", Color) = (1.0, 1.0, 1.0, 1.0)
_Mask ("Mask", Vector) = (1.0, 1.0, 1.0, 1.0)
}
SubShader {
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
LOD 100
Pass {
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Lighting Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
uniform sampler2D _MainTex;
uniform float4 _Mask;
uniform fixed4 _FrostColor;
struct Attribute {
float4 vertex : POSITION;
half2 texcoord : TEXCOORD0;
};
struct Varying {
float4 pos : SV_POSITION;
half2 uv : TEXCOORD1;
};
Varying vert(Attribute a) {
Varying v;
v.pos = mul(UNITY_MATRIX_MVP, a.vertex);
v.uv = a.texcoord;
return v;
}
fixed4 frag(Varying v) : COLOR {
fixed4 c = tex2D(_MainTex, v.uv);
float r = step(0.1f, _Mask.x*c.r)*c.r*2.0f;
float b = step(0.1f, _Mask.y*c.b)*.5f;
fixed4 res = _FrostColor;
res.a = max(max(r, _Mask.z*c.g), b);
return res;
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment