DistortEffectCamera.cs 566 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using UnityEngine;
  3. namespace Distort
  4. {
  5. public class DistortEffectCamera : MonoBehaviour
  6. {
  7. private void Start()
  8. {
  9. }
  10. private void OnRenderImage(RenderTexture source, RenderTexture destination)
  11. {
  12. RenderTexture active = RenderTexture.active;
  13. RenderTexture.active = this.rt;
  14. Graphics.Blit(source, this.rt);
  15. RenderTexture.active = active;
  16. this.RenderMaterial.SetTexture("_MainTex", this.rt);
  17. Graphics.Blit(source, destination);
  18. }
  19. public Material RenderMaterial;
  20. public RenderTexture rt;
  21. }
  22. }