UI and renderTextures

Hi Everyone,

I’m posting here since in haven’t found anyone with a similar issue.

I created a system for my game to display my backgrounds. It creates a canvas in front of a camera that record the image to a render texture. That texture is then applied to the main canvas.

Why doing so? for 2 main reasons:
1- because sometimes i have to blur the background. And since mobile devices can’t handle blurring very well, i activate the camera once, and then shut it down. this way, the processor don’t have to calculate the blur every frames thus lowering the framerate for no reason.
2- because of the transitions. i used a canvasgroup to lower the alpha when i switch backgrounds, but the way it worked made some elements apparent during the fade. And i wanted some elements to stay hidden.

So what is the problem?

Android

on Unity and PC, no problem, see for yourself

But on android builds, it renders this:

At first I thought it had something to do with the render texture parameters, but i’m not sure anymore.

5349402--540240--RT.jpg

Does anyone know what causes that, and how to get render textures to work correctly on Android?

Maybe on android your images are rendering as quads without alpha, which causes them to render black pixels where you would rather render nothing.

Or maybe it is rendering your images as quads with depth first, then when the background is being rendered, it does not render to those transparent pixels that think something closer to the camera has already been rendered to them.

I haven’t done much mobile development, but if there is a way to get the Unity frame debugger to work on your phone, you can watch every object get rendered one at a time to see if your background renders with those squares or if they get drawn over the background.

Best of luck!

Thanks Gambit,

i tried that but I couldn’t any informations from the frame debugger.

But I just managed to git it to work!!
I found that it i set the canvas not in screenspace-Camera but in world space, everything works fine.
Why? I don’t have a clue… but it works so i’m happy.

ERRATUM
Didn’t worked, my main camera was in front of the 3D canvas…

Try:

  • change your render texture format to R8G8B8A8_UNorm
  • No depth buffer (unrelated but not needed)

THANK YOU le_Tai!! it worked!