Take a look at this repository on github named GaussianBlur
simpleBlit.cs uses a simple function to blit and set a texture2D which is desired by you as the source of the blit functionality
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Graphics.Blit(_baseTexture, destination);
}
filterTest then creates a material at runtime and sets your custom shader on it (the project includes a shader that may suit your scenario).
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
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, destination);
RenderTexture.ReleaseTemporary(rt1);
RenderTexture.ReleaseTemporary(rt2);
}