Moved ActiveVessel check from UpdateModules to FixedUpdate
[VesselSimulator.git] / Assets / PartTools / Shaders / ScrollingUnlit.shader
cybutek 1 Shader "KSP/FX/ScrollingUnlit"
2 {
3 Properties
4 {
5 _MainTex("MainTex (RGB Alpha(A))", 2D) = "white" {}
6 _Color("Color (RGB Alpha(A))", Color) = (1,1,1,1)
7 [Space]
8 _SpeedX("Scroll Speed X", Float) = 0
9 _SpeedY("Scroll Speed Y", Float) = 1
10 [Space]
11 [KeywordEnum(UV, Screen Space)] _TexCoord("Texture Coordinates", Float) = 0
12 _TileX("ScreenSpace Tiling X", Float) = 1
13 _TileY("ScreenSpace Tiling Y", Float) = 1
14 [Space]
15 [KeywordEnum(Off, Outer, Inner)] _Fresnel("Fresnel Fade", Float) = 0
16 _FresnelPow("Fresnel Falloff", Range(0,5)) = 1
17 _FresnelInt("Fresnel Intensity", Range(0,1)) = 1
18 }
19
20 SubShader
21 {
22 Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
23
24 Pass
25 {
26 ZWrite On
27 ColorMask 0
28 }
29
30 ZWrite On
31 ZTest LEqual
32 Blend SrcAlpha OneMinusSrcAlpha
33
34 CGPROGRAM
35
36 #include "LightingKSP.cginc"
37 #pragma surface surf Unlit noforwardadd noshadow noambient novertexlights alpha:fade
38 #pragma target 3.0
39 #pragma multi_compile _TEXCOORD_UV _TEXCOORD_SCREEN_SPACE
40 #pragma multi_compile _FRESNEL_OFF _FRESNEL_OUTER _FRESNEL_INNER
41
42
43 sampler2D _MainTex;
44
45 float _SpeedX;
46 float _SpeedY;
47 float _TileX;
48 float _TileY;
49
50 #if !_FRESNEL_OFF
51 float _FresnelPow;
52 float _FresnelInt;
53 #endif
54
55 struct Input
56 {
57 #if _TEXCOORD_UV
58 float2 uv_MainTex;
59 #endif
60
61 #if _TEXCOORD_SCREEN_SPACE
62 float4 screenPos;
63 #endif
64
65 #if !_FRESNEL_OFF
66 float3 viewDir;
67 #endif
68 };
69
70
71
72 void surf (Input IN, inout SurfaceOutput o)
73 {
74 #if _TEXCOORD_SCREEN_SPACE
75 float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
76 screenUV.x += _Time * _SpeedX;
77 screenUV.y += _Time * _SpeedY;
78 screenUV.x *= _TileX;
79 screenUV.y *= _TileY;
80 float4 c = tex2D(_MainTex, (screenUV));
81 #endif
82
83
84 #if _TEXCOORD_UV
85 fixed2 scrollUV = IN.uv_MainTex ;
86 fixed xScrollValue = _SpeedX * _Time.x;
87 fixed yScrollValue = _SpeedY * _Time.x;
88 scrollUV += fixed2(xScrollValue, yScrollValue);
89 half4 c = tex2D(_MainTex, scrollUV);
90 #endif
91 float3 normal = float3(0,0,1);
92
93 o.Albedo = c.rgb * _Color.rgb;
94 o.Normal = normal;
95 o.Alpha = c.a * _Color.a;
96
97 #if _FRESNEL_INNER
98 half rim = 1.0 - saturate(dot(normalize(IN.viewDir), float3(0, 0, 1)));
99 o.Alpha *= lerp(pow(rim, _FresnelPow), 1, 1- _FresnelInt);
100 #endif
101 #if _FRESNEL_OUTER
102 half rim = 1.0 - saturate(dot(normalize(IN.viewDir), float3(0, 0, 1)));
103 o.Alpha *= lerp(pow(1 - rim, _FresnelPow), 1, 1 - _FresnelInt);
104 #endif
105
106 }
107 ENDCG
108 }
109 }