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