private void Awake()
 {
     if (current)
     {
         Debug.LogError("There should only be one Directional light in this Scene!");
         Destroy(this);
         return;
     }
     current                     = this;
     directionalLight            = GetComponent <Light>();
     shadowCam                   = GetComponent <Camera>();
     shadowCam.enabled           = false;
     shadowCam.cullingMask       = directionalLight.cullingMask;
     shadowCam.orthographic      = true;
     shadowCam.renderingPath     = RenderingPath.Forward;
     shadowCam.clearFlags        = CameraClearFlags.Nothing;
     shadowMapTexture            = new RenderTexture(4096, 4096, 16, RenderTextureFormat.RGFloat, RenderTextureReadWrite.Linear);
     shadowMapTexture.filterMode = FilterMode.Point;
     shadowCam.targetTexture     = shadowMapTexture;
     shadowCam.SetReplacementShader(Shader.Find(depthShader), "RenderType");
 }
 private void OnDestroy()
 {
     current = null;
     shadowMapTexture.Release();
     Destroy(shadowMapTexture);
 }