Search Unity

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

Discussion in 'Editor & General Support' started by PixelSquad, Oct 20, 2015.

  1. PixelSquad

    PixelSquad

    Joined:
    Sep 4, 2014
    Posts:
    114
    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:

    http://answers.unity3d.com/questions/997174/unity-ui-rendertexture-broken-since-501p4.html

    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
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,299
    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.
     
  3. PixelSquad

    PixelSquad

    Joined:
    Sep 4, 2014
    Posts:
    114
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,299
    The issue referred to in the thread is fixed in 5.2.2p2. Should be out very soon.
     
  5. PixelSquad

    PixelSquad

    Joined:
    Sep 4, 2014
    Posts:
    114
    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?
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,299
    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.
     
  7. PixelSquad

    PixelSquad

    Joined:
    Sep 4, 2014
    Posts:
    114
    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<Camera>().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.
     
    karl_jones likes this.
  8. Katkuti

    Katkuti

    Joined:
    May 30, 2014
    Posts:
    2
    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
     
  9. greg-harding

    greg-harding

    Joined:
    Apr 11, 2013
    Posts:
    524
    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/re...n-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
     
    Last edited: Nov 14, 2015
  10. AbandonedCart

    AbandonedCart

    Joined:
    Mar 4, 2014
    Posts:
    72
    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.
     
    Last edited: May 11, 2017
  11. eunsoossi

    eunsoossi

    Joined:
    Apr 6, 2018
    Posts:
    8
    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.
     
  12. AbandonedCart

    AbandonedCart

    Joined:
    Mar 4, 2014
    Posts:
    72
    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.