Hello, Im having an issue with my custom shader changing the color of the object when inside and outside of the Quality’s shadow distance setting.
In this picture I set one chunk of grass to the default shader provided by unity and it works fine. If anyone may know why this is happening, I’m all ears
Shader
Shader "Custom/Cubes" {
Properties {
_Color("Colour (RGBA)", Color) = (0,0,0,1)
_Strength("Strength",Range(0, 0.5))=0.01
_Darken("Darken", Range(0,1))=0
_RenderDistance("Render Detail Distance", Float)=35
}
SubShader {
Tags {
"RenderType"="Opaque"
}
LOD 200
Cull Back
CGPROGRAM
#pragma surface surf Standard
float4 _Color;
float _Strength;
float _Darken;
float _RenderDistance;
struct Input {
float3 worldPos;
};
float rand(float3 myVector) {
return frac(sin(dot(myVector, float3(12.9898,78.233,45.5432))) * 43758.5453);
}
void surf (Input IN, inout SurfaceOutputStandard o) {
float3 vWPos = IN.worldPos;
float dist = distance(_WorldSpaceCameraPos, vWPos);
if(dist <= _RenderDistance) {
float randNoise = rand(round(vWPos * 2)) * _Strength;
float3 noise = float3(randNoise, randNoise, randNoise);
o.Albedo = (_Darken == 0 ? noise : -noise) + _Color.xyz;
} else {
o.Albedo = _Color.xyz;
}
o.Alpha = 1;
o.Smoothness = 0.25f;
}
ENDCG
}
FallBack "Diffuse"
}