Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question How do i prevent video textures that share a shader from batching on Android?

Discussion in 'General Graphics' started by PsiconLab, Sep 13, 2023.

  1. PsiconLab

    PsiconLab

    Joined:
    Oct 9, 2017
    Posts:
    27
    How do i prevent video textures that share a shader from batching on Android?

    I'm finding when I play back several video textures at the same time they share resources and swap from one to the other at runtime. The textures are actually part of Depthkit's Unity package to display their 3D mesh content which draws it's data from the video clips. I've tried a bunch of things to stop this happening but am struggling to really get it to stop.

    So I'm trying to build from Unity 2021.3.2f1 for the Quest 2 VR headset (Android) from URP with ARM64, ASTC compression, IL2CPP. The whole thing looks fine in Unity Editor but when I build for Android and look in the headset it just keeps occurring.

    Here's what I've tried to fix it...
    • Disabling "static" on the Gameobjects did not fix it
    • Disabling "GPU instancing" on the materials did not fix it
    • Disabling "Static batching" in Player preferences did not fix it
    • Using individual materials for each video texture did not fix it
    • Using individual shaders on the materials did not fix it
    • Changing from OpenGLES3 to Vulkan fixed it once - but not in my current project
    • Building Android as ARM v7 fixed it somehow once- but I can't use this in my current project
    In this Depthkit forum post they recommend disbaling "SRP Batching" in the URP quality settings, but it doesn't show for me.

    I'm running out of ideas...
    • could it be that the mesh renderers share a shader? is that the problem?
    • My shader in the Inspector states "disable batching : no" is it this?
    • Is it to do with Texture compression?
    • Is it a rendering/GPU issue?
    • Is it that the Quest has cached a shader and is just showing me the old shader so I'm not even sure if my changes are being displayed properly?
    • I've been told to use AVPro which I don't have, is it to do with Unity's Video Player somehow?
    Any ideas/pointers would be welcome!

    It's driving me up the wall - what causes this swapping/sharing and how can i find a fix?

    Ben
     
  2. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    691
    Hi Ben,

    this question is probably better suited for the Depthkit forum, but I'll give it a shot.

    According to post you linked, this should already be fixed in the latest version:
    However, you can try disabling the SRP batcher via the debug settings
    upload_2023-9-13_9-27-41.png
    You can also break SRP batcher compatibility by either making the shader or renderer incompatible. See here:
    https://docs.unity3d.com/Manual/SRPBatcher.html
     
  3. PsiconLab

    PsiconLab

    Joined:
    Oct 9, 2017
    Posts:
    27
    Ah right, well spotted, I'm an up date behind... I'll try both! Thanks for the swift reply... fingers crossed...
     
    c0d3_m0nk3y likes this.
  4. PsiconLab

    PsiconLab

    Joined:
    Oct 9, 2017
    Posts:
    27
    Well, for the record it wasn't that I was behind on the Depthkit package... but this didn't fix it for me sadly
     
  5. PsiconLab

    PsiconLab

    Joined:
    Oct 9, 2017
    Posts:
    27
    I've found that this does not happen for Debug builds - just for release builds. What could be affecting it and is there a way to disable it?