Light.layerShadowCullDistances not working
Light.layerShadowCullDistances isn't culling my shadows;
How To Reproduce :
Create a new scene;
Delete the Directional Light;
Create a cube;
Put the cube as child of the camera;
Set It's Transform.localPosition to 0f,0f,30f;
Create a PointLight;
Set It as Child of the Camera;
Set it's Transform.localPosition to 0f,0f,0f;
Set Point light to cast soft shadows;
Set point light range do 3000;
Set point light intensity to 3000;
Set in quality settings shadow distance do 3000;
Attach to the light the script below :
using UnityEngine;
public class CullShadows : MonoBehaviour
{
private bool everyFrame;
public float distance;
private void OnEnable() { if (everyFrame) return; SetShadowCullingDistances(); }
private void Update() { if (!everyFrame) return; SetShadowCullingDistances(); }
private void SetShadowCullingDistances()
{
var layers = new float[32];
for (int i = 0; i < 32; i++) { layers[i] = 1f; }
GetComponent<Light>().layerShadowCullDistances = layers;
}
}
Press play; There will always have 1 shadow caster at least;
Your answer
Follow this Question
Related Questions
Problem with bake shadow 0 Answers
Light Shadow problem 1 Answer
Multiple lights shading problem 0 Answers
How to remove baked shadow artifacts? 0 Answers
Shadows not the same in editor game tap, and the game build! Bug? 0 Answers