- Home /
Unity 5 rendertexture postprocess procedure on PC.
What is the proper way of doing some postfx like blur, i've read quite some topics about this and I'm still not sure which way to go with it. At the moment I'm creating a rendertexture and assigning it to camera, then I'm blitting it to the screen, but all I get is black screen. I've also tried Graphics.Blit(src, dest, mat) in OnRenderImage method, but it only works, when I do not assign render texture to the camera, does anyone have any clues what's going on?
using UnityEngine;
using System.Collections;
public class TestBlur : MonoBehaviour
{
private RenderTexture rt;
public Material mat;
void Start()
{
rt = new RenderTexture(Screen.width, Screen.height, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
mat.SetTexture("_MainTex", rt);
GetComponent<Camera>().targetTexture = rt;
}
void OnPostRender()
{
Graphics.Blit(rt, null, mat);
}
}
Comment