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\$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.