using UnityEngine; using System.Collections; using UnityEngine.Video; [RequireComponent (typeof(Camera))] public class VHSPostProcessEffect : MonoBehaviour { Material m; public Shader shader; public VideoPlayer VHS; float yScanline, xScanline; void Start() { m = new Material(shader); m.SetTexture("_VHSTex", VHS.texture); VHS.isLooping = true; VHS.Play(); } void OnRenderImage(RenderTexture source, RenderTexture destination){ yScanline += Time.deltaTime * 0.1f; xScanline -= Time.deltaTime * 0.1f; if(yScanline >= 1){ yScanline = Random.value; } if(xScanline <= 0 || Random.value < 0.05){ xScanline = Random.value; } m.SetFloat("_yScanline", yScanline); m.SetFloat("_xScanline", xScanline); Graphics.Blit(source, destination, m); } }