RenderTexture full of noise on ios

I try to get FBX model render texture from camera
but I got this
6190290--678747--2.png
wtf? noise around? android was fine but it happen on ios only .

Unity ver:2019.4.3f1

MainCamera Setting:
Depth only
Culling mask β€”> fbx model layer
Depth: 0

BackgroundCamera Setting:
Solid Color : red color
Depth: -1

so I try to render with nothing but a background image(blue image background)
I got this
6190290--678744--1.png

then I go to create a new scene , drop the cameras, add simple test script, and every thing was fine! so how does this happen??? help plz

        public Texture2D GetCameraRenderImage()
        {

            Rect rect = new Rect(0, 0, MainCamera.pixelWidth, MainCamera.pixelHeight);
            RenderTexture renderTexture = new RenderTexture(MainCamera.pixelWidth, MainCamera.pixelHeight, 24, RenderTextureFormat.ARGB32);
            Texture2D screenShot = new Texture2D(MainCamera.pixelWidth, MainCamera.pixelHeight, TextureFormat.ARGB32, false);

            MainCamera.targetTexture = renderTexture;
            MainCamera.Render();

            RenderTexture.active = renderTexture;

            screenShot.ReadPixels(rect, 0, 0);
            screenShot.Apply();

            MainCamera.targetTexture = null;
            RenderTexture.active = null;

            Destroy(renderTexture);
            renderTexture = null;

            return screenShot;
        }

Try clearing render texture before rendering to it.
I’ve had similar issue for the android, and that seems to be trick to fix it.

E.g. via GL.Clear:

GL.Clear(true, true, Color.black);

Also, if you don’t need depth, I suggest specifying 0 instead of 24 on the constructor;
Also, its cheaper to use Unity - Scripting API: RenderTexture.GetTemporary instead of creating each time a new render texture.

2 Likes