33 lines
731 B
C#
33 lines
731 B
C#
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
|
|
namespace Artngame.SKYMASTER
|
|
{
|
|
[ExecuteInEditMode]
|
|
public class CopyShadowMapSM : MonoBehaviour
|
|
{
|
|
private CommandBuffer cb;
|
|
|
|
private void OnEnable()
|
|
{
|
|
Light component = GetComponent<Light>();
|
|
if ((bool)component)
|
|
{
|
|
cb = new CommandBuffer();
|
|
cb.name = "CopyShadowMap";
|
|
cb.SetGlobalTexture("_DirectionalShadowMask", new RenderTargetIdentifier(BuiltinRenderTextureType.CurrentActive));
|
|
component.AddCommandBuffer(LightEvent.AfterScreenspaceMask, cb);
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
Light component = GetComponent<Light>();
|
|
if ((bool)component)
|
|
{
|
|
component.RemoveCommandBuffer(LightEvent.AfterScreenspaceMask, cb);
|
|
}
|
|
}
|
|
}
|
|
}
|