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

38 lines
688 B
C#

using UnityEngine;
public class Snow : MonoBehaviour
{
public GameObject snowPlane;
public Material blitmat;
public Material white;
public float updateSpeed = 100f;
private Camera cam;
private bool backgroundset;
private void Start()
{
cam = GetComponent<Camera>();
cam.depthTextureMode = DepthTextureMode.Depth;
cam.orthographicSize *= snowPlane.transform.localScale.x;
}
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
blitmat.SetFloat("_Speed", updateSpeed);
if (!backgroundset)
{
Graphics.Blit(source, destination, white);
backgroundset = true;
}
else
{
Graphics.Blit(source, destination, blitmat);
}
}
}