Skip to content

Instantly share code, notes, and snippets.

@jean-moreno
Created November 3, 2017 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jean-moreno/dccc58ceb87e9c886cb8d1a2f3af791e to your computer and use it in GitHub Desktop.
Save jean-moreno/dccc58ceb87e9c886cb8d1a2f3af791e to your computer and use it in GitHub Desktop.
Quick shader with animatable emission color based on a specific texture (red = mask, green = animation)
Shader "Custom/pillar_shader"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
[Space]
_EmissionTex ("Emission", 2D) = "white" {}
[HDR] _EmissionColor ("Emission Color", Color) = (1,1,1,0)
[Space]
_Anim ("Animation", Float) = 0
_Smooth ("Smoothing", Float) = 1
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Standard fullforwardshadows nometa nolightmap
#pragma target 3.0
sampler2D _MainTex;
sampler2D _EmissionTex;
float4 _EmissionColor;
struct Input
{
float2 uv_MainTex;
float2 uv_EmissionTex;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
float _Anim;
float _Smooth;
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
half4 emissionTex = tex2D(_EmissionTex, IN.uv_EmissionTex);
half3 emission = emissionTex.r * _EmissionColor.rgb * saturate(-emissionTex.g*_Smooth + _Anim*_Smooth);
o.Emission = emission.rgb * _EmissionColor.rgb;
}
ENDCG
}
FallBack "Diffuse"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment