не хочу переходить в 2020, ради одного шейдера.
Нужно перековертировать из Standart в Unlit shader. С поддержкой полных теней и спекулар (в дальнейшим с отражениям)
Синтаксис:
Используется csharp
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MaskColor ("Dirt Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_DirtTex ("Dirt Tex (RGB)", 2D) = "zero" {}
_BurnTex("Burn Tex (RGB)", 2D) = "zero" {}
_Dirtness ("Dirtness", Range(0,1)) = 0.5
_Burn("Burn", Range(0,1)) = 0.5
_Glossiness ("Smoothness", Range(0,1)) = 0.5
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
cull off
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
sampler2D _DirtTex;
sampler2D _BurnTex;
struct Input {
float2 uv_MainTex;
};
half _Dirtness;
half _Glossiness;
half _Burn;
fixed4 _Color;
fixed4 _MaskColor;
void surf (Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
fixed4 main = tex2D(_MainTex, IN.uv_MainTex) * _Color;
fixed4 dirt = tex2D(_DirtTex, IN.uv_MainTex);
fixed4 burnTex = tex2D(_BurnTex, IN.uv_MainTex);
fixed4 tex = lerp(main, _MaskColor, dirt * _Dirtness);
o.Albedo = lerp(tex, burnTex, _Burn);
// Metallic and smoothness come from slider variables
o.Smoothness = ((tex.a - (dirt * _Dirtness))) * _Glossiness - _Burn;
}
ENDCG
}
_Color ("Color", Color) = (1,1,1,1)
_MaskColor ("Dirt Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_DirtTex ("Dirt Tex (RGB)", 2D) = "zero" {}
_BurnTex("Burn Tex (RGB)", 2D) = "zero" {}
_Dirtness ("Dirtness", Range(0,1)) = 0.5
_Burn("Burn", Range(0,1)) = 0.5
_Glossiness ("Smoothness", Range(0,1)) = 0.5
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
cull off
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
sampler2D _DirtTex;
sampler2D _BurnTex;
struct Input {
float2 uv_MainTex;
};
half _Dirtness;
half _Glossiness;
half _Burn;
fixed4 _Color;
fixed4 _MaskColor;
void surf (Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
fixed4 main = tex2D(_MainTex, IN.uv_MainTex) * _Color;
fixed4 dirt = tex2D(_DirtTex, IN.uv_MainTex);
fixed4 burnTex = tex2D(_BurnTex, IN.uv_MainTex);
fixed4 tex = lerp(main, _MaskColor, dirt * _Dirtness);
o.Albedo = lerp(tex, burnTex, _Burn);
// Metallic and smoothness come from slider variables
o.Smoothness = ((tex.a - (dirt * _Dirtness))) * _Glossiness - _Burn;
}
ENDCG
}