Skip to content

Instantly share code, notes, and snippets.

@IJEMIN
Created January 20, 2018 18:58
Show Gist options
  • Save IJEMIN/945fc610a3494420fbc35504fe986db9 to your computer and use it in GitHub Desktop.
Save IJEMIN/945fc610a3494420fbc35504fe986db9 to your computer and use it in GitHub Desktop.
Thermal Effect on Unity Shader
Shader "Custom/TermalRed" {
Properties {
_NormalTex("Normal Texture",2D) = "white" {}
_DistanceFadeOut("DistanceFadeOut",Range(0,3)) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Lambert noambient
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _NormalTex;
float _DistanceFadeOut;
struct Input {
float2 uv_NormalTex;
float3 viewDir;
//float3 worldPos;
};
void surf (Input IN, inout SurfaceOutput o) {
o.Normal = UnpackNormal(tex2D(_NormalTex,IN.uv_NormalTex));
float lightOpacity = dot(IN.viewDir,o.Normal);
lightOpacity = pow(lightOpacity,2);
o.Emission = float3(max(1-_DistanceFadeOut,0),max(0,lightOpacity-_DistanceFadeOut),max(0,0.5-lightOpacity));
}
ENDCG
}
FallBack "Diffuse"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment