Hello! I have a surface shader, which blends some textures. It doesn’t receive shadows. What is the problem?
Shader "Custom/TextureBlend" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_NoiseTex ("NoiseGREY", 2D) = "asd" {}
_SandTex ("Sand", 2D) = "sdf" {}
_SnowTex ("Snow", 2D) = "dfg" {}
_GrassTex ("Grass", 2D) = "dfg" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_BlendSmoothness ("BlendSmoothness", Range(1,50)) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" "Queue" = "Geometry" }
LOD 200
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 _NoiseTex;
sampler2D _SandTex;
sampler2D _SnowTex;
sampler2D _GrassTex;
struct Input {
float2 uv_NoiseTex;
float2 uv_SandTex;
float2 uv_SnowTex;
float2 uv_GrassTex;
};
half _Glossiness;
half _BlendSmoothness;
half _Metallic;
fixed4 _Color;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_CBUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_CBUFFER_END
void surf (Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
float4 inp = tex2D(_NoiseTex, IN.uv_NoiseTex);
float m = 2.0;
float _m = 1 / m;
uint sh = inp.r > 0.5;
uint fh = inp.r <= 0.5;
float4 a = atan((inp - _m / 2 - _m * sh) * _BlendSmoothness) * 0.364 + 0.5;
float4 c = (tex2D(_SnowTex, IN.uv_SnowTex) * sh + tex2D(_SandTex, IN.uv_SandTex) * fh) * a * m;
c += (tex2D(_SandTex, IN.uv_SandTex) * sh + tex2D(_GrassTex, IN.uv_GrassTex) * fh) * (1 - a) * m;
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = 1;
}
ENDCG
}
FallBack "Diffuse"
}