root / Assets / Time of Day / Assets / Shaders / Cloud Billboard Near.shader @ 175:f9f5640c2a3a
History | View | Annotate | Download (1.8 kB)
1 | // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' |
---|---|
2 | |
3 | Shader "Time of Day/Cloud Billboard Near" |
4 | { |
5 | Properties |
6 | { |
7 | _MainTex ("Density Map (RGBA)", 2D) = "white" {} |
8 | _BumpMap ("Normal Map", 2D) = "bump" {} |
9 | } |
10 | |
11 | CGINCLUDE |
12 | #include "UnityCG.cginc" |
13 | #include "TOD_Base.cginc" |
14 | #include "TOD_Clouds.cginc" |
15 | #define TOD_SCATTERING_RAYLEIGH 0 |
16 | #include "TOD_Scattering.cginc" |
17 | |
18 | uniform sampler2D _MainTex; |
19 | uniform sampler2D _BumpMap; |
20 | |
21 | uniform float4 _MainTex_ST; |
22 | uniform float4 _BumpMap_ST; |
23 | |
24 | struct v2f { |
25 | float4 position : SV_POSITION; |
26 | float4 color : TEXCOORD0; |
27 | float4 texcoord : TEXCOORD1; |
28 | float3 viewDir : TEXCOORD2; |
29 | float3 lightDir : TEXCOORD3; |
30 | float3 lightCol : TEXCOORD4; |
31 | }; |
32 | |
33 | v2f vert(appdata_tan v) { |
34 | v2f o; |
35 | |
36 | o.position = TOD_TRANSFORM_VERT(v.vertex); |
37 | |
38 | o.texcoord.xy = TRANSFORM_TEX(v.texcoord, _MainTex); |
39 | o.texcoord.zw = TRANSFORM_TEX(v.texcoord, _BumpMap); |
40 | |
41 | o.viewDir = normalize(mul(TOD_World2Sky, mul(unity_ObjectToWorld, v.vertex)).xyz); |
42 | o.lightDir = TOD_LocalSunDirection; |
43 | o.lightCol = ScatteringColor(o.viewDir, TOD_CloudScattering); |
44 | |
45 | o.color.rgb = CloudColor(o.viewDir, o.lightDir); |
46 | o.color.a = TOD_CloudOpacity; |
47 | |
48 | TANGENT_SPACE_ROTATION; |
49 | o.viewDir = normalize(mul(rotation, o.viewDir)); |
50 | o.lightDir = normalize(mul(rotation, o.lightDir)); |
51 | |
52 | return o; |
53 | } |
54 | |
55 | half4 frag(v2f i) : COLOR { |
56 | return CloudBillboardColor(_MainTex, _BumpMap, i.texcoord, i.color, i.viewDir, i.lightDir, i.lightCol); |
57 | } |
58 | ENDCG |
59 | |
60 | SubShader |
61 | { |
62 | Tags |
63 | { |
64 | "Queue"="Geometry+540" |
65 | "RenderType"="Background" |
66 | "IgnoreProjector"="True" |
67 | } |
68 | |
69 | Pass |
70 | { |
71 | ZWrite Off |
72 | ZTest LEqual |
73 | Blend SrcAlpha OneMinusSrcAlpha |
74 | Fog { Mode Off } |
75 | |
76 | CGPROGRAM |
77 | #pragma vertex vert |
78 | #pragma fragment frag |
79 | #pragma multi_compile _ TOD_CLOUDS_DENSITY |
80 | #pragma multi_compile _ TOD_CLOUDS_BUMPED |
81 | ENDCG |
82 | } |
83 | } |
84 | |
85 | Fallback Off |
86 | } |