1
\$\begingroup\$

I found a nice Gaussian Blur shader online and am attempting to use it to blur a render texture using blit(). However, the render texture remains unblurred. I know for a fact the blur shader works as I've used it to blur the main camera, but it just doesn't seem to want to blit() my render texture.

C# Blur Script:

 void Update()
 {
     if (_material == null)
     {
         _material = new Material(_shader);
         _material.hideFlags = HideFlags.HideAndDontSave;
     }

     RenderTexture rt1, rt2;

     if (_downSampleMode == DownSampleMode.Half)
     {
         rt1 = RenderTexture.GetTemporary(source.width / 2, source.height / 2);
         rt2 = RenderTexture.GetTemporary(source.width / 2, source.height / 2);
         Graphics.Blit(source, rt1);
     }
     else if (_downSampleMode == DownSampleMode.Quarter)
     {
         rt1 = RenderTexture.GetTemporary(source.width / 4, source.height / 4);
         rt2 = RenderTexture.GetTemporary(source.width / 4, source.height / 4);
         Graphics.Blit(source, rt1, _material, 0);
     }
     else
     {
         rt1 = RenderTexture.GetTemporary(source.width, source.height);
         rt2 = RenderTexture.GetTemporary(source.width, source.height);
         Graphics.Blit(source, rt1);
     }

     for (var i = 0; i < _iteration; i++)
     {
         Graphics.Blit(rt1, rt2, _material, 1);
         Graphics.Blit(rt2, rt1, _material, 2);
     }

     Graphics.Blit(rt1, source);

     RenderTexture.ReleaseTemporary(rt1);
     RenderTexture.ReleaseTemporary(rt2);
}
\$\endgroup\$
0

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.