运动模糊,代码如下:

 1 using UnityEngine;
 2 
 3 public class MotionBlurRenderer : PostEffectRenderer
 4 {
 5     [Range(0.1f, 0.9f)]
 6     [SerializeField]
 7     float m_blurAmount = 0.1f;
 8 
 9     RenderTexture m_accumulationTexture;
10 
11     void OnDisable()
12     {
13         DestroyImmediate(m_accumulationTexture);
14     }
15 
16     protected override void OnRenderImage(RenderTexture src, RenderTexture dest)
17     {
18         if (!m_accumulationTexture || m_accumulationTexture.width != src.width || m_accumulationTexture.height != src.height)
19         {
20             DestroyImmediate(m_accumulationTexture);
21             m_accumulationTexture = new RenderTexture(src.width, src.height, 0);
22             //m_accumulationTexture.hideFlags = HideFlags.HideAndDontSave;
23             Graphics.Blit(src, m_accumulationTexture);
24         }
25 
26         //m_accumulationTexture.MarkRestoreExpected();
27 
28         Mat.SetFloat("_BlurAmount", m_blurAmount);
29 
30         Graphics.Blit(src, m_accumulationTexture, Mat);
31         Graphics.Blit(m_accumulationTexture, dest);
32 
33         base.OnRenderImage(src, dest);
34     }
35 
36     protected override string ShaderName
37     {
38         get { return "Custom/Study/Motion Shader"; }
39     }
40 }
MotionBlurRenderer

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2021-11-16
  • 2022-12-23
  • 2021-11-14
  • 2021-04-26
猜你喜欢
  • 2021-10-20
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案