Render Texture showing black square on Android

Hello,

I am quite new to using render textures and I am currently trying to use them to display models in the UI, while in the editor its working pretty much fine and in the PC build, in the android build it’s showing up as a black square, I have messed around with the clear flags of the camera, different color formats of the texture and shaders for the materials however to no avail. I am currently using the default rendering pipeline for Unity. Am I missing something? The current android version I am testing on is Android 9. Thanks.

The code here converts the render texture in a texture 2d and then applies it to the raw image

 void ApplyTexture()
        {
           
            Texture2D texture = new Texture2D(_renderTexture.width, _renderTexture.height, TextureFormat.RGBA32, false); 
            renderCamera.Render();
            RenderTexture.active = _renderTexture;
            texture.ReadPixels(new Rect(0, 0, _renderTexture.width, _renderTexture.height), 0, 0);
            texture.Apply();
            _image.texture = texture;
       
        }

7939762--1015336--upload_2022-3-4_6-13-54.png7939762--1015342--upload_2022-3-4_6-14-17.png

This is currently what its showing:

7939762--1015336--upload_2022-3-4_6-13-54.png

I manage to fix the issue by changing my code for copying what the render texture sees following the example provided by unity. If anyone else is having the same issue this is a good place to look at, just apply the texture2D it returns to your raw image texture and that seemed to make it work.

2 Likes

Hey mate! I have the same problem I need your help how do u manage to solve it. I posted question over here or Render Texture showing black in raw image. - Questions & Answers - Unity Discussions.

My solution was in changing RenderTexture.depthStencilFormat by render texture. Seems like device don’t working with 32 bit depth buffer
8452478--1121399--upload_2022-9-20_14-55-35.png

12 Likes

Yes, it really worked for me!

1 Like

good job

I changed it D24_UNIFORM works for me Unity 2021.3