Part Tools Import
[VesselSimulator.git] / Assets / PartTools / Shaders / AlphaSpecular.shader
cybutek 1 Shader "KSP/Alpha/Translucent Specular"
2 {
3 Properties
4 {
5 _MainTex("MainTex (RGBA)", 2D) = "white" {}
6
7 //_Gloss ("Gloss", Range (0.01, 1)) = 0.5
8 _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
9 _Shininess ("Shininess", Range (0.03, 1)) = 0.078125
10
11
12 _Opacity("_Opacity", Range(0,1)) = 1
13 _Fresnel("Fresnel", Range(0,10)) = 0
14 [MaterialToggle] _FresnelInvert("Invert Fresnel", Float) = 0
15 _RimFalloff("Rim Falloff", Range(0.01,5) ) = 0.1
16 _RimColor("Rim Color", Color) = (0,0,0,0)
17
18 _TemperatureColor("_TemperatureColor", Color) = (0,0,0,0)
19 _BurnColor ("Burn Color", Color) = (1,1,1,1)
20 }
21
22 SubShader
23 {
24 Tags { "Queue" = "Transparent" }
25
26 Pass
27 {
28 ZWrite On
29 ColorMask 0
30 }
31
32 //ZWrite On
33 ZTest LEqual
34 Blend SrcAlpha OneMinusSrcAlpha
35
36 CGPROGRAM
37
38 #include "LightingKSP.cginc"
39 #pragma surface surf BlinnPhongSmooth alpha:fade
40 #pragma target 3.0
41
42 half _Shininess;
43
44 sampler2D _MainTex;
45
46 //float _Gloss;
47
48 float _Opacity;
49 float _Fresnel;
50 float _FresnelInvert;
51 float _RimFalloff;
52 float4 _RimColor;
53 float4 _TemperatureColor;
54 float4 _BurnColor;
55
56
57 struct Input
58 {
59 float2 uv_MainTex;
60 float2 uv_BumpMap;
61 float2 uv_Emissive;
62 float3 viewDir;
63 };
64
65 void surf (Input IN, inout SurfaceOutput o)
66 {
67 float4 color = tex2D(_MainTex, (IN.uv_MainTex)) * _BurnColor;
68
69 float3 normal = float3(0,0,1);
70 half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
71
72 float3 fresnel = (_FresnelInvert + (pow(1 - rim, _Fresnel))) * (1 - _FresnelInvert + 1 - (pow(1 - rim, _Fresnel)));
73
74 float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
75 emission += _TemperatureColor.rgb * _TemperatureColor.a;
76
77 o.Albedo = color.rgb;
78 o.Emission = emission;
79 o.Gloss = color.a;
80 o.Specular = _Shininess;
81 o.Normal = normal;
82 o.Emission *= _Opacity;
83 o.Alpha = _Opacity * color.a * fresnel;
84 }
85
86 ENDCG
87 }
88 Fallback "Standard"
89 }