Part Tools Import
[VesselSimulator.git] / Assets / PartTools / Shaders / LightwrapSpecular.shader
cybutek 1 Shader "KSP/Lightwrapped/Specular"
2 {
3 Properties
4 {
5 _MainTex("_MainTex (RGB spec(A))", 2D) = "white" {}
6 _Color ("Light Wrapping", Color) = (0,0,0,0)
7 _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
8 _Shininess ("Shininess", Range (0.03, 1)) = 0.4
9 _LightBoost("Light Boost", Range(1, 2)) = 1.0
10
11 _Opacity("_Opacity", Range(0,1) ) = 1
12 _RimFalloff("_RimFalloff", Range(0.01,5) ) = 0.1
13 _RimColor("_RimColor", Color) = (0,0,0,0)
14 }
15
16 SubShader
17 {
18 ZWrite On
19 ZTest LEqual
20 Blend SrcAlpha OneMinusSrcAlpha
21
22 CGPROGRAM
23
24 #include "LightingKSP.cginc"
25 #pragma surface surf LightWrapped
26 #pragma target 3.0
27
28
29
30
31 half _Shininess;
32
33
34 sampler2D _MainTex;
35
36 float _Opacity;
37 float _RimFalloff;
38 float4 _RimColor;
39
40
41 struct Input
42 {
43 float2 uv_MainTex;
44 float3 viewDir;
45 };
46
47 void surf (Input IN, inout SurfaceOutput o)
48 {
49 float4 color = tex2D(_MainTex,(IN.uv_MainTex));
50 float3 normal = float3(0,0,1);
51
52 half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
53
54 float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
55
56 o.Albedo = color.rgb;
57 o.Emission = emission;
58 o.Gloss = color.a * _Shininess;
59 o.Specular = color.a * _Shininess;
60 o.Normal = normal;
61
62 o.Emission *= _Opacity;
63 o.Alpha = _Opacity;
64 }
65 ENDCG
66 }
67 Fallback "Diffuse"
68 }