RadialBlurEffect.cs 931 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using UnityEngine;
  2. using System.Collections;
  3. public class RadialBlurEffect : PostEffectBase
  4. {
  5. [Range(1, 32)]
  6. public int IterationNumber = 16;
  7. [Range(0, 1)]
  8. public float Intensity = 0.1f;
  9. [Range(-1, 1)]
  10. public float CenterX = 0;
  11. [Range(-1, 1)]
  12. public float CenterY = 0;
  13. private void OnRenderImage(RenderTexture source, RenderTexture destination)
  14. {
  15. if(Mat)
  16. {
  17. Mat.SetFloat("_IterationNumber", IterationNumber);
  18. Mat.SetFloat("_Intensity", Intensity);
  19. Mat.SetFloat("_OffsetX", CenterX + 0.5f);
  20. Mat.SetFloat("_OffsetY", CenterY + 0.5f);
  21. Graphics.Blit(source, destination, Mat);
  22. }
  23. else
  24. {
  25. Graphics.Blit(source, destination);
  26. }
  27. }
  28. public void FadeIn()
  29. {
  30. this.enabled = true;
  31. }
  32. public void FadeOut()
  33. {
  34. this.enabled = false;
  35. }
  36. }