Render texture works in editor but not on devices after upgrade to Unity 5

Hi there

I have a problem where render textures work well on the editor, but just renders totally black on the devices (android and iOS).

We are not using Unity UI, but it’s similar to the following:

It started happening when we moved from Unity 4 to Unity 5.

Has anyone experienced this problem? Is it a common bug, or something changed in the way we should handle render textures?

Many thanks

The bug you linked to has been fixed and was added to our backport queue this week, so its likely to appear in a patch in the next week or two. If that does not fix your problem then open a new bug.

Hi Karl. I upgraded to 5.2.2p1, and the problem persists.

Is the linked bug resolved in this version? Or is it in the upcoming version?

Please note we’re not using Unity UI, but it looks like a bug since it’s different behaviour in the editor / devices.

The issue referred to in the thread is fixed in 5.2.2p2. Should be out very soon.

Hi Karl. I just picked the update and it didn’t resolve our problem.

Any ideas? Is there anything else that could have changed from 4 to 5 in this area? Something extra we need to do to get it working on iOS / Android?

The best thing to do is file a bug report with a sample project. If something is broken it can then be fixed if not we can advise what you are doing wrong.

Hi Karl

Just letting you know that unfortunately I didn’t file a bug report, but I resolved the problem with the following:

  1. Added a script to the camera and implemented OnPostRender()
  2. Called the code that read the screen into the texture on the OnPostRender() function.

I noticed that OnPostRender() is called under camera.GetComponent().Render();

So effectively from my end everything is called in the same order as before.

The only difference is that for it to work on iOS it needs to be inside OnPostRender() where it works fine if it’s called after the call to Camera.Render() in the editor.

Perhaps would be nice if it was consistent on iOS / Editor, or make it explicit in the documentation that ReadPixels should be called on OnPostRender, or give a warning in case it’s called outside, etc, maybe would save other people some time.

1 Like

Hi Karl,
i am facing the same in a project that converted from 4.6 to 5.2.2f ?
Would this be covered in the next build?
Thanx

Have you tried disabling anti-aliasing on iOS/Android? We’re having problems with grabpasses on Unity 5.1.x - 5.2.2f1 iOS when anti-aliasing is enabled (screen goes black). It works fine when anti-aliasing is disabled and always works ok in the editor and standalone.

We submitted bugs/repos (Original case 729439. Repo assigned Case 736412) but they’ve not been looked at just yet. There’s some forum feedback from Unity/ @Alexey saying that 5.3 beta didn’t show the same problem as we’re seeing with our project/repo using the current stable version of Unity. (http://forum.unity3d.com/threads/rendertexture-not-working-on-ios-and-android-unity-4-2-0f4.192561/page-2). We’re currently not using the patch releases due to the series of problems they kept having with UI in some previous patches.

Edit: QA has looked at the problem and due to technical stuff with Metal and performance implications of workarounds the problem won’t be fixed. @Alexey has also said that Metal + AA affects some of the pipeline and there are no plans to workaround the issues. Basically the advice is to not use grabpasses (in shaders) when using Metal with AA. We could try to use rendertextures, but instead we’re using CommandBuffers to grab the current screen.

cheers,

// greg

Found the issue. It was the Camera output to texture (in my case).

It appears that is broken, but doing the process in code allowed any variation of generating the RenderTexture to work. It seems the issue is in the Editor itself, not rendering.

What does this mean?

I have same problem after update from 2018.1 to 2018.2

There was no problem when I use 2018.1 version.

How can I fix this?

Thanks.

It means I did not assign the texture in the editor, but wrote code to perform the operation.

I don’t know what changes have occurred after Unity went to year-based versioning. I purchased a perpetual license for Unity 5 and was appalled with the quality of both the product and support, so I had no intention of investing more.