Statistics
| Branch: | Tag: | Revision:

root / Assets / Time of Day / Assets / Shaders / Sun.shader @ 175:f9f5640c2a3a

History | View | Annotate | Download (1.1 kB)

1
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
2
3
Shader "Time of Day/Sun"
4
{
5
	Properties
6
	{
7
	}
8
9
	CGINCLUDE
10
	#include "UnityCG.cginc"
11
	#include "TOD_Base.cginc"
12
13
	struct v2f {
14
		float4 position : SV_POSITION;
15
		half3  tex      : TEXCOORD0;
16
	};
17
18
	v2f vert(appdata_base v) {
19
		v2f o;
20
21
		o.position = TOD_TRANSFORM_VERT(v.vertex);
22
23
		float3 skyPos = mul(TOD_World2Sky, mul(unity_ObjectToWorld, v.vertex)).xyz;
24
25
		o.tex.xy = 2.0 * v.texcoord - 1.0;
26
		o.tex.z  = skyPos.y * 25;
27
28
		return o;
29
	}
30
31
	half4 frag(v2f i) : COLOR {
32
		half4 color = half4(TOD_SunMeshColor, 1);
33
34
		half dist = length(i.tex.xy);
35
36
		half sun  = step(dist, 0.5) * TOD_SunMeshBrightness;
37
		half glow = smoothstep(0.0, 1.0, 1.0 - pow(dist, TOD_SunMeshContrast)) * saturate(TOD_SunMeshBrightness);
38
39
		color.rgb *= saturate(i.tex.z) * (sun + glow);
40
41
		return color;
42
	}
43
	ENDCG
44
45
	SubShader
46
	{
47
		Tags
48
		{
49
			"Queue"="Background+30"
50
			"RenderType"="Background"
51
			"IgnoreProjector"="True"
52
		}
53
54
		Pass
55
		{
56
			ZWrite Off
57
			ZTest LEqual
58
			Blend One One
59
			Fog { Mode Off }
60
61
			CGPROGRAM
62
			#pragma vertex vert
63
			#pragma fragment frag
64
			ENDCG
65
		}
66
	}
67
68
	Fallback Off
69
}