Moved ActiveVessel check from UpdateModules to FixedUpdate
[VesselSimulator.git] / Assets / PartTools / Shaders / Emissive.shader
cybutek 1 Shader "KSP/Emissive/Diffuse"
2 {
3 Properties
4 {
5 _MainTex("_MainTex (RGB)", 2D) = "gray" {}
6
7 _EmissiveColor("_EmissiveColor", Color) = (0,0,0,1)
8 _Emissive("_Emissive", 2D) = "white" {}
9
10 _Opacity("_Opacity", Range(0,1) ) = 1
11 _RimFalloff("_RimFalloff", Range(0.01,5) ) = 0.1
12 _RimColor("_RimColor", Color) = (0,0,0,0)
13
14 _TemperatureColor("_TemperatureColor", Color) = (0,0,0,0)
15 _BurnColor ("Burn Color", Color) = (1,1,1,1)
16
17 }
18
19 SubShader
20 {
21 ZWrite On
22 ZTest LEqual
23 Blend SrcAlpha OneMinusSrcAlpha
24
25 CGPROGRAM
26
27 #include "LightingKSP.cginc"
28 #pragma surface surf BlinnPhongSmooth keepalpha
29 #pragma target 3.0
30
31 sampler2D _MainTex;
32
33 float4 _EmissiveColor;
34 sampler2D _Emissive;
35
36 float _Opacity;
37 float _RimFalloff;
38 float4 _RimColor;
39 float4 _TemperatureColor;
40 float4 _BurnColor;
41
42
43 struct Input
44 {
45 float2 uv_MainTex;
46 float2 uv_Emissive;
47 float3 viewDir;
48 };
49
50 void surf (Input IN, inout SurfaceOutput o)
51 {
52 float4 color = tex2D(_MainTex,(IN.uv_MainTex)) * _BurnColor;
53 float3 normal = float3(0,0,1);
54
55 half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
56
57 float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
58 emission += _TemperatureColor.rgb * _TemperatureColor.a;
59 emission += (tex2D(_Emissive, IN.uv_Emissive).rgb * _EmissiveColor.rgb) * _EmissiveColor.a;
60
61 o.Albedo = color.rgb;
62 o.Emission = emission;
63 o.Gloss = 0;
64 o.Specular = 0;
65 o.Normal = normal;
66
67 o.Emission *= _Opacity;
68 o.Alpha = _Opacity;
69 }
70 ENDCG
71 }
72 Fallback "Standard"
73 }