Files
2026-03-04 10:03:45 +08:00

34 lines
671 B
C#

using UnityEngine;
[RequireComponent(typeof(Camera))]
[ExecuteInEditMode]
[AddComponentMenu("Effects/Crepuscular Rays", -1)]
public class Crepuscular : MonoBehaviour
{
public Material material;
public GameObject light;
private void Start()
{
light = GameObject.Find("Directional Light");
if (!light)
{
base.enabled = false;
}
}
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if ((bool)light)
{
material.SetVector("_LightPos", GetComponent<Camera>().WorldToViewportPoint(base.transform.position - light.transform.forward));
Graphics.Blit(source, destination, material);
}
}
private void Update()
{
}
}