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

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

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


You can also break SRP batcher compatibility by either making the shader or renderer incompatible. See here:

Ah right, well spotted, I’m an up date behind… I’ll try both! Thanks for the swift reply… fingers crossed…

1 Like

Well, for the record it wasn’t that I was behind on the Depthkit package… but this didn’t fix it for me sadly

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?