Created
January 20, 2018 18:58
-
-
Save IJEMIN/945fc610a3494420fbc35504fe986db9 to your computer and use it in GitHub Desktop.
Thermal Effect on Unity Shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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