Commit fd5966e2f7ac7f2a9454a3769c8e53a5878cf6a7
1 parent
dc793fb404
Exists in
master
added/imported shaders from Infinite Runner.
Showing 11 changed files with 377 additions and 0 deletions Side-by-side Diff
- Assets/_Shaders/Infinite Runner Shaders.meta
- Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve Additive.shader
- Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve Additive.shader.meta
- Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve Alpha Blend.shader
- Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve Alpha Blend.shader.meta
- Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve Specular.shader
- Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve Specular.shader.meta
- Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve.shader
- Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve.shader.meta
- Assets/_Shaders/Infinite Runner Shaders/Transparent Cutout.shader
- Assets/_Shaders/Infinite Runner Shaders/Transparent Cutout.shader.meta
Assets/_Shaders/Infinite Runner Shaders.meta
Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve Additive.shader
1 | +Shader "Infinite Runner/Diffuse Curve Additive" { | |
2 | + Properties { | |
3 | + _FadeOutColor ("Fade Out Color", Color) = (0, 0, 0, 0) | |
4 | + _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) | |
5 | + _MainTex ("Particle Texture", 2D) = "white" {} | |
6 | + _NearCurve ("Near Curve", Vector) = (0, 0, 0, 0) | |
7 | + _FarCurve ("Far Curve", Vector) = (0, 0, 0, 0) | |
8 | + _Dist ("Distance Mod", Float) = 0.0 | |
9 | + } | |
10 | + SubShader { | |
11 | + Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } | |
12 | + Blend SrcAlpha One | |
13 | + AlphaTest Greater .01 | |
14 | + ColorMask RGB | |
15 | + Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) } | |
16 | + | |
17 | + Pass { // pass 0 | |
18 | + CGPROGRAM | |
19 | + #pragma vertex vert | |
20 | + #pragma fragment frag | |
21 | + #pragma fragmentoption ARB_precision_hint_fastest | |
22 | + #pragma multi_compile_particles | |
23 | + | |
24 | + #include "UnityCG.cginc" | |
25 | + | |
26 | + uniform sampler2D _MainTex; | |
27 | + uniform float4 _MainTex_ST; | |
28 | + uniform float4 _FadeOutColor; | |
29 | + uniform float4 _TintColor; | |
30 | + uniform float4 _NearCurve; | |
31 | + uniform float4 _FarCurve; | |
32 | + uniform float _Dist; | |
33 | + | |
34 | + struct fragmentInput | |
35 | + { | |
36 | + float4 pos : POSITION; | |
37 | + fixed4 color : COLOR; | |
38 | + float2 uv : TEXCOORD0; | |
39 | + float distanceSquared : TEXCOORD1; | |
40 | + }; | |
41 | + | |
42 | + fragmentInput vert(appdata_full v) | |
43 | + { | |
44 | + fragmentInput o; | |
45 | + | |
46 | + // Apply the curve | |
47 | + float4 pos = mul(UNITY_MATRIX_MV, v.vertex); | |
48 | + o.distanceSquared = pos.z * pos.z * _Dist; | |
49 | + pos.x += (_NearCurve.x - max(1.0 - o.distanceSquared / _FarCurve.x, 0.0) * _NearCurve.x); | |
50 | + pos.y += (_NearCurve.y - max(1.0 - o.distanceSquared / _FarCurve.y, 0.0) * _NearCurve.y); | |
51 | + o.pos = mul(UNITY_MATRIX_P, pos); | |
52 | + o.color = v.color; | |
53 | + o.uv = TRANSFORM_TEX(v.texcoord,_MainTex); | |
54 | + | |
55 | + return o; | |
56 | + } | |
57 | + | |
58 | + fixed4 frag(fragmentInput i) : COLOR | |
59 | + { | |
60 | + return lerp(2.0f * i.color * _TintColor * tex2D(_MainTex, i.uv), _FadeOutColor, max(i.distanceSquared / _FarCurve.z, 0.0)); | |
61 | + } | |
62 | + | |
63 | + ENDCG | |
64 | + } // end pass | |
65 | + } | |
66 | +} |
Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve Additive.shader.meta
Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve Alpha Blend.shader
1 | +Shader "Infinite Runner/Diffuse Curve Alpha Blend" { | |
2 | + Properties { | |
3 | + _FadeOutColor ("Fade Out Color", Color) = (0, 0, 0, 0) | |
4 | + _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) | |
5 | + _MainTex ("Particle Texture", 2D) = "white" {} | |
6 | + _NearCurve ("Near Curve", Vector) = (0, 0, 0, 0) | |
7 | + _FarCurve ("Far Curve", Vector) = (0, 0, 0, 0) | |
8 | + _Dist ("Distance Mod", Float) = 0.0 | |
9 | + } | |
10 | + SubShader { | |
11 | + Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } | |
12 | + Blend SrcAlpha OneMinusSrcAlpha | |
13 | + AlphaTest Greater .01 | |
14 | + ColorMask RGB | |
15 | + Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) } | |
16 | + | |
17 | + Pass { // pass 0 | |
18 | + CGPROGRAM | |
19 | + #pragma vertex vert | |
20 | + #pragma fragment frag | |
21 | + #pragma fragmentoption ARB_precision_hint_fastest | |
22 | + #pragma multi_compile_particles | |
23 | + | |
24 | + #include "UnityCG.cginc" | |
25 | + | |
26 | + uniform sampler2D _MainTex; | |
27 | + uniform float4 _MainTex_ST; | |
28 | + uniform float4 _FadeOutColor; | |
29 | + uniform float4 _TintColor; | |
30 | + uniform float4 _NearCurve; | |
31 | + uniform float4 _FarCurve; | |
32 | + uniform float _Dist; | |
33 | + | |
34 | + struct fragmentInput | |
35 | + { | |
36 | + float4 pos : POSITION; | |
37 | + fixed4 color : COLOR; | |
38 | + float2 uv : TEXCOORD0; | |
39 | + float distanceSquared : TEXCOORD1; | |
40 | + }; | |
41 | + | |
42 | + fragmentInput vert(appdata_full v) | |
43 | + { | |
44 | + fragmentInput o; | |
45 | + | |
46 | + // Apply the curve | |
47 | + float4 pos = mul(UNITY_MATRIX_MV, v.vertex); | |
48 | + o.distanceSquared = pos.z * pos.z * _Dist; | |
49 | + pos.x += (_NearCurve.x - max(1.0 - o.distanceSquared / _FarCurve.x, 0.0) * _NearCurve.x); | |
50 | + pos.y += (_NearCurve.y - max(1.0 - o.distanceSquared / _FarCurve.y, 0.0) * _NearCurve.y); | |
51 | + o.pos = mul(UNITY_MATRIX_P, pos); | |
52 | + o.color = v.color; | |
53 | + o.uv = TRANSFORM_TEX(v.texcoord,_MainTex); | |
54 | + | |
55 | + return o; | |
56 | + } | |
57 | + | |
58 | + fixed4 frag(fragmentInput i) : COLOR | |
59 | + { | |
60 | + return lerp(2.0f * i.color * _TintColor * tex2D(_MainTex, i.uv), _FadeOutColor, max(i.distanceSquared / _FarCurve.z, 0.0)); | |
61 | + } | |
62 | + | |
63 | + ENDCG | |
64 | + } // end pass | |
65 | + } | |
66 | +} |
Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve Alpha Blend.shader.meta
Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve Specular.shader
1 | +Shader "Infinite Runner/Diffuse Curve Specular" { | |
2 | + Properties { | |
3 | + _Color ("Color", Color) = (1.0, 1.0, 1.0, 1.0) | |
4 | + _AdditiveColor ("Additive Color", Color) = (1.0, 1.0, 1.0, 1.0) | |
5 | + _SpecColor("Specular Color", Color) = (1.0, 1.0, 1.0, 1.0) | |
6 | + _Shininess ("Shininess", Float) = 10 | |
7 | + _FadeOutColor ("Fade Out Color", Color) = (0, 0, 0, 0) | |
8 | + _NearCurve ("Near Curve", Vector) = (0, 0, 0, 0) | |
9 | + _FarCurve ("Far Curve", Vector) = (0, 0, 0, 0) | |
10 | + _Dist ("Distance Mod", Float) = 0.0 | |
11 | + } | |
12 | + SubShader { | |
13 | + Tags { "RenderType"="Opaque" } | |
14 | + | |
15 | + Pass { // pass 0 | |
16 | + | |
17 | + Tags { "LightMode" = "ForwardBase" } | |
18 | + | |
19 | + CGPROGRAM | |
20 | + #pragma vertex vert | |
21 | + #pragma fragment frag | |
22 | + #pragma fragmentoption ARB_precision_hint_fastest | |
23 | + #include "UnityCG.cginc" | |
24 | + | |
25 | + uniform float4 _Color; | |
26 | + uniform float4 _AdditiveColor; | |
27 | + uniform float4 _SpecColor; | |
28 | + uniform float _Shininess; | |
29 | + uniform float4 _FadeOutColor; | |
30 | + uniform float4 _NearCurve; | |
31 | + uniform float4 _FarCurve; | |
32 | + uniform float _Dist; | |
33 | + | |
34 | + uniform float4 _LightColor0; | |
35 | + | |
36 | + struct fragmentInput | |
37 | + { | |
38 | + float4 pos : SV_POSITION; | |
39 | + float4 posWorld : TEXCOORD0; | |
40 | + float3 normalDir : TEXCOORD1; | |
41 | + float distanceSquared : TEXCOORD2; | |
42 | + }; | |
43 | + | |
44 | + fragmentInput vert(appdata_full v) | |
45 | + { | |
46 | + fragmentInput o; | |
47 | + | |
48 | + // Apply the curve | |
49 | + float4 pos = mul(UNITY_MATRIX_MV, v.vertex); | |
50 | + o.distanceSquared = pos.z * pos.z * _Dist; | |
51 | + pos.x += (_NearCurve.x - max(1.0 - o.distanceSquared / _FarCurve.x, 0.0) * _NearCurve.x); | |
52 | + pos.y += (_NearCurve.y - max(1.0 - o.distanceSquared / _FarCurve.y, 0.0) * _NearCurve.y); | |
53 | + o.pos = mul(UNITY_MATRIX_P, pos); | |
54 | + | |
55 | + o.posWorld = mul(UNITY_MATRIX_P, pos); | |
56 | + o.normalDir = normalize(mul(float4(v.normal, 0.0), _World2Object).xyz); | |
57 | + | |
58 | + return o; | |
59 | + } | |
60 | + | |
61 | + fixed4 frag(fragmentInput i) : COLOR | |
62 | + { | |
63 | + float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.posWorld.xyz); | |
64 | + float atten = 2.0; | |
65 | + float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz); | |
66 | + float3 diffuseReflection = atten * _LightColor0.xyz * max(0.0, dot(i.normalDir, lightDirection)); | |
67 | + float3 specularReflection = atten * _LightColor0.xyz * _SpecColor.rgb * max(0.0, dot(i.normalDir, lightDirection)) * pow(max(0.0, dot(reflect(-lightDirection, i.normalDir), viewDirection)), _Shininess); | |
68 | + float3 lightFinal = diffuseReflection + specularReflection + UNITY_LIGHTMODEL_AMBIENT + _AdditiveColor; | |
69 | + | |
70 | + return lerp(float4(lightFinal * _Color.rgb, 1.0), _FadeOutColor, max(i.distanceSquared / _FarCurve.z, 0.0)); | |
71 | + } | |
72 | + | |
73 | + ENDCG | |
74 | + } // end pass | |
75 | + } | |
76 | + FallBack "Diffuse" | |
77 | +} |
Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve Specular.shader.meta
Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve.shader
1 | +// Upgrade NOTE: commented out 'half4 unity_LightmapST', a built-in variable | |
2 | +// Upgrade NOTE: commented out 'sampler2D unity_Lightmap', a built-in variable | |
3 | +// Upgrade NOTE: replaced tex2D unity_Lightmap with UNITY_SAMPLE_TEX2D | |
4 | + | |
5 | +Shader "Infinite Runner/Diffuse Curve" { | |
6 | + Properties { | |
7 | + _MainTex ("Main Texture", 2D) = "black" {} | |
8 | + _FadeOutColor ("Fade Out Color", Color) = (0, 0, 0, 0) | |
9 | + _NearCurve ("Near Curve", Vector) = (0, 0, 0, 0) | |
10 | + _FarCurve ("Far Curve", Vector) = (0, 0, 0, 0) | |
11 | + _Dist ("Distance Mod", Float) = 0.0 | |
12 | + } | |
13 | + SubShader { | |
14 | + Tags { "RenderType"="Opaque" } | |
15 | + | |
16 | + Pass { // pass 0 | |
17 | + | |
18 | + Tags { "LightMode" = "ForwardBase" } | |
19 | + | |
20 | + CGPROGRAM | |
21 | + #pragma vertex vert | |
22 | + #pragma fragment frag | |
23 | + #pragma fragmentoption ARB_precision_hint_fastest | |
24 | + #pragma multi_compile_fwdbase LIGHTMAP_OFF LIGHTMAP_ON | |
25 | + #include "UnityCG.cginc" | |
26 | + #ifndef SHADOWS_OFF | |
27 | + #include "AutoLight.cginc" | |
28 | + #endif | |
29 | + | |
30 | + uniform sampler2D _MainTex; | |
31 | + uniform half4 _MainTex_ST; | |
32 | + uniform half4 _MainTex_TexelSize; | |
33 | + // uniform sampler2D unity_Lightmap; | |
34 | + // uniform half4 unity_LightmapST; | |
35 | + uniform float4 _FadeOutColor; | |
36 | + uniform float4 _NearCurve; | |
37 | + uniform float4 _FarCurve; | |
38 | + uniform float _Dist; | |
39 | + | |
40 | + uniform float4 _LightColor0; | |
41 | + | |
42 | + struct fragmentInput | |
43 | + { | |
44 | + float4 pos : SV_POSITION; | |
45 | + half2 uv : TEXCOORD0; | |
46 | + half2 uvLM : TEXCOORD1; | |
47 | + float distanceSquared : TEXCOORD2; | |
48 | + #ifndef SHADOWS_OFF | |
49 | + LIGHTING_COORDS(3,4) | |
50 | + #endif | |
51 | + }; | |
52 | + | |
53 | + fragmentInput vert(appdata_full v) | |
54 | + { | |
55 | + fragmentInput o; | |
56 | + | |
57 | + // Apply the curve | |
58 | + float4 pos = mul(UNITY_MATRIX_MV, v.vertex); | |
59 | + o.distanceSquared = pos.z * pos.z * _Dist; | |
60 | + pos.x += (_NearCurve.x - max(1.0 - o.distanceSquared / _FarCurve.x, 0.0) * _NearCurve.x); | |
61 | + pos.y += (_NearCurve.y - max(1.0 - o.distanceSquared / _FarCurve.y, 0.0) * _NearCurve.y); | |
62 | + o.pos = mul(UNITY_MATRIX_P, pos); | |
63 | + o.uv = v.texcoord.xy * _MainTex_ST.xy + _MainTex_ST.zw; | |
64 | + o.uvLM = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; | |
65 | + | |
66 | + #if UNITY_UV_STARTS_AT_TOP | |
67 | + if (_MainTex_TexelSize.y < 0) | |
68 | + o.uv.y = 1.0-o.uv.y; | |
69 | + #endif | |
70 | + | |
71 | + #ifndef SHADOWS_OFF | |
72 | + TRANSFER_VERTEX_TO_FRAGMENT(o); | |
73 | + #endif | |
74 | + | |
75 | + return o; | |
76 | + } | |
77 | + | |
78 | + fixed4 frag(fragmentInput i) : COLOR | |
79 | + { | |
80 | + fixed4 color = tex2D(_MainTex, i.uv); | |
81 | + | |
82 | + #ifdef LIGHTMAP_ON | |
83 | + fixed3 lm = DecodeLightmap (UNITY_SAMPLE_TEX2D (unity_Lightmap, i.uvLM)); | |
84 | + color.rgb *= lm; | |
85 | + #endif | |
86 | + | |
87 | + #ifndef SHADOWS_OFF | |
88 | + fixed atten = LIGHT_ATTENUATION(i); | |
89 | + color.rgb *= atten; | |
90 | + #endif | |
91 | + | |
92 | + return lerp(color, _FadeOutColor, max(i.distanceSquared / _FarCurve.z, 0.0)); | |
93 | + } | |
94 | + | |
95 | + ENDCG | |
96 | + } // end pass | |
97 | + } | |
98 | + FallBack "Diffuse" | |
99 | +} |
Assets/_Shaders/Infinite Runner Shaders/Diffuse Curve.shader.meta
Assets/_Shaders/Infinite Runner Shaders/Transparent Cutout.shader
1 | +Shader "Infinite Runner/Transparent Cutout" { | |
2 | + Properties { | |
3 | + _MainTex ("Main Texture", 2D) = "black" {} | |
4 | + _TintColor ("Tint Color", Color) = (0, 0, 0, 0) | |
5 | + _Cutoff ("Alpha Cutoff", Range(0, 1)) = 0.0 | |
6 | + } | |
7 | + SubShader { | |
8 | + Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} | |
9 | + Blend SrcAlpha OneMinusSrcAlpha | |
10 | + | |
11 | + Pass { // pass 0 | |
12 | + | |
13 | + CGPROGRAM | |
14 | + #pragma vertex vert_img | |
15 | + #pragma fragment frag | |
16 | + #pragma fragmentoption ARB_precision_hint_fastest | |
17 | + #include "UnityCG.cginc" | |
18 | + | |
19 | + uniform sampler2D _MainTex; | |
20 | + uniform fixed4 _TintColor; | |
21 | + uniform float _Cutoff; | |
22 | + | |
23 | + fixed4 frag(v2f_img i) : COLOR | |
24 | + { | |
25 | + fixed4 color = tex2D(_MainTex, i.uv); | |
26 | + color.a = color.a * (1 - step(color.a, _Cutoff)); | |
27 | + | |
28 | + return color * _TintColor; | |
29 | + } | |
30 | + | |
31 | + ENDCG | |
32 | + } // end pass | |
33 | + } | |
34 | + FallBack "Diffuse" | |
35 | +} |
Assets/_Shaders/Infinite Runner Shaders/Transparent Cutout.shader.meta