I’m having a hard time getting my RenderTexture to work. The idea is simple enough. The camera just shows a plane. I now create a RenderTexture at Startup and set the material.texture of the plane to my newly created RenderTexture. On Update I draw another texture (brush) into the RT. The good new is that it works. Unfortunately sometimes the brush is drawn “twice” AND it is drawn at a another position and in a different scale. This does not happen all the time. If I delay my draw calls significantly (i.e. 1 per second) it can be that 3 times the brush is drawn at the wanted position, the fourth time the effect described above happens. It is not predictable.
renderTexture = new RenderTexture(1024, 1024, 0, RenderTextureFormat.ARGB32);
canvas.renderer.material.mainTexture = renderTexture;
In Update() I basically do this:
RenderTexture.active = renderTexture;
Graphics.DrawTexture(new Rect(400, 200, 128, 128), brush);
RenderTexture.active = null;
I never Release() the RT by the way. A check before drawing shows that renderTexture.IsCreated() is always true. The behaviour is observed in the Unity IDE Windows 3.4.2.
I’m running out of ideas now. Any help appreciated.
Ben