Part Tools Import
[VesselSimulator.git] / Assets / PartTools / Shaders / SpecularTransparent.shader
cybutek 1 Shader "KSP/Specular (Transparent)"
2 {
3 Properties
4 {
5 _MainTex("_MainTex (RGB spec(A))", 2D) = "white" {}
6 _MainColor ("Main Color", Color) = (1,1,1,1)
7
8 _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
9
10 _Opacity("_Opacity", Range(0,1) ) = 1
11 _Fresnel("Fresnel", Range(0,10)) = 0
12 [MaterialToggle] _FresnelInvert("Invert Fresnel", Float) = 0
13
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 SubShader
22 {
23 Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
24
25 Pass
26 {
27 ZWrite On
28 ColorMask 0
29 }
30
31 //ZWrite On
32 ZTest LEqual
33 Blend SrcAlpha OneMinusSrcAlpha
34
35 CGPROGRAM
36
37 #include "LightingKSP.cginc"
38 #pragma surface surf BlinnPhongSmooth alpha:fade
39 #pragma target 3.0
40
41 half _Shininess;
42
43 sampler2D _MainTex;
44
45 float4 _MainColor;
46 float _Opacity;
47 float _RimFalloff;
48 float4 _RimColor;
49 float4 _TemperatureColor;
50 float4 _BurnColor;
51 float _Fresnel;
52 float _FresnelInvert;
53
54 struct Input
55 {
56 float2 uv_MainTex;
57 float3 viewDir;
58 float3 worldNormal;
59 };
60
61 void surf (Input IN, inout SurfaceOutput o)
62 {
63 float4 color = tex2D(_MainTex,(IN.uv_MainTex)) * _MainColor * _BurnColor;
64 half rim = 1.0 - saturate(dot (normalize(IN.viewDir), IN.worldNormal));
65
66 float3 fresnel = (_FresnelInvert + (pow(1 - rim, _Fresnel))) * (1 - _FresnelInvert + 1 - (pow(1 - rim, _Fresnel)));
67
68 float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
69 emission += _TemperatureColor.rgb * _TemperatureColor.a;
70
71 o.Albedo = color.rgb;
72 o.Emission = emission;
73 o.Gloss = color.a;
74 o.Specular = _Shininess;
75 o.Emission *= _Opacity;
76 o.Alpha = _Opacity * color.a * fresnel;
77 }
78 ENDCG
79
80 }
81 Fallback "Standard"
82 }