Синтаксис:
Используется glsl
Shader "Custom/Atmo1"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
[PowerSlider(4)] _Fading("Fading texture", Range(0.1, 5)) = 1.0
[PowerSlider(4)] _AtmoWidth("Atmosphere density", Range(0.1, 5)) = 1.0
[Header(Culling)]
[Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Float) = 2 //"Back"
[Enum(Off,0,On,1)]_ZWrite ("ZWrite", Float) = 1.0
}
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
Cull [_Cull]
ZWrite [_ZWrite]
LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows alpha:fade
#pragma target 3.0
sampler2D _MainTex;
fixed4 _Color;
float _Fading;
float _FadingAlpha;
fixed _AtmoWidth;
struct Input
{
float2 uv_MainTex;
float3 viewDir;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed a = dot(_WorldSpaceLightPos0, o.Normal);
fixed a2 = 1 - pow(1 - clamp(a, 0, 1), _Fading);
fixed a3 = dot(o.Normal, IN.viewDir);
float2 uv = float2(a2, 0.0);
fixed4 c = tex2D (_MainTex, uv) * _Color * _LightColor0;
o.Albedo = c.rgb;
o.Alpha = pow(1 - clamp(abs(a3), 0, 1), 5.0 - _AtmoWidth) * c.a;
}
ENDCG
}
FallBack "Diffuse"
}
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
[PowerSlider(4)] _Fading("Fading texture", Range(0.1, 5)) = 1.0
[PowerSlider(4)] _AtmoWidth("Atmosphere density", Range(0.1, 5)) = 1.0
[Header(Culling)]
[Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Float) = 2 //"Back"
[Enum(Off,0,On,1)]_ZWrite ("ZWrite", Float) = 1.0
}
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
Cull [_Cull]
ZWrite [_ZWrite]
LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows alpha:fade
#pragma target 3.0
sampler2D _MainTex;
fixed4 _Color;
float _Fading;
float _FadingAlpha;
fixed _AtmoWidth;
struct Input
{
float2 uv_MainTex;
float3 viewDir;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed a = dot(_WorldSpaceLightPos0, o.Normal);
fixed a2 = 1 - pow(1 - clamp(a, 0, 1), _Fading);
fixed a3 = dot(o.Normal, IN.viewDir);
float2 uv = float2(a2, 0.0);
fixed4 c = tex2D (_MainTex, uv) * _Color * _LightColor0;
o.Albedo = c.rgb;
o.Alpha = pow(1 - clamp(abs(a3), 0, 1), 5.0 - _AtmoWidth) * c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Текстура: слева направо ==> ночь -> день (альфа учитывается)