Ways to blit into a texture? (iOS compatible)

I’m working a drawing app, and my current solution of using Graphics.Blit() to draw the brush on the canvas works perfectly on editor but it doesn’t work on iOS.

My rendertexture turns black as soon as I use a material in the Blit() method when running on iOS. I was wondering if there are other ways to blit into a texture.


When you use a material with a custom shader for blit, you need to make sure that it handles depth correctly. In DX9, any shader seems to work, but it is important for DX11 and apparently OpenGL ES.

If you look at the built-in blit shader (DefaultResources/Internal-BlitCopy.shader) you see that it uses ZTest Always to make sure that the texture gets written, regardless of what’s in the depth buffer. It also does some other useful things such as disabling fog with Fog { Mode Off }.

About other ways to blit to a texture: Blit draws a full screen quad with the given material to the active RenderTexture, which is something you could do manually.

When you initialise ‘RenderTexture’ and want it to work on iOS you need to set depth to 0. I figured it out the hard way… Wasted one week to find workaround for this.