MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Border Light Issues on Mixed Reality Toolkit/Standard materials when building onto Android with Dynamic Batching

Open septianrazi opened this issue 3 years ago • 2 comments

Describe the bug

Mixed Reality Toolkit/Standard Materials with Border Lights will have it's Border Light Width seemingly increase when multiple of the same Materials need to be rendered. If only one instance is rendered, material border width is displayed normally.

May have something to do with Mesh Draw Call Batching as disabling Dynamic Batching in the Player settings for the project eliminates the issue

To reproduce

Steps to reproduce the behavior:

  1. Add multiple GameObjects into a scene with the same Mixed Reality Toolkit/Standard material that includes Border width (many of the default gameObjects from the MRTK toolbox can be used)
  2. Ensure Dynamic Batching is checked in Player settings
  3. Target build for Android
  4. Build for Android
  5. Open the app in an Oculus device, and ensure multiple gameObjects are within view

Expected behavior

Material border width should say consistent even when multiple materials of the same instance need to be rendered with Dynamic Batching

Screenshots

This is what it looks like in an Oculus Quest 2 Android build:

au csiro ie LabTrainDev-20220709-113328

These are the default Slates and Tooltips in MRTK Toolbox, yet border width is different compared to in Editor which would be the expected behaviour:

OculusScreenshot1665546773

Your setup

  • Unity Version 2021.3.11f1
  • MRTK Version 2.7.3
  • OpenXR Plugin 1.4.2

Target platform

  • Oculus Quest 2 with OpenXR

Additional context

Issue only occurred after upgrading from Unity 2020.3.30f1 to 2021.3.11f1

septianrazi avatar Oct 12 '22 04:10 septianrazi

Assigning @Cameron-Micka .

Zee2 avatar Oct 12 '22 18:10 Zee2

Thank you for reporting this @septianrazi. I think your hypothesis is correct:

May have something to do with Mesh Draw Call Batching as disabling Dynamic Batching in the Player settings for the project eliminates the issue

If a MRTK/Standard shader material is batched and uses a feature requiring object scale, then you will see artifacts like this.

To avoid this issue, we automatically enable GPU instancing on the material which also has the side effect of disabling batching: image

My guess is Unity 2021.3.11f1 Unity no longer respects that flag and performs batching anyway.

But, there may be a better solution. As a test could you change this line in MixedRealityStandard.shader: Tags{ "RenderType" = "Opaque" "LightMode" = "ForwardBase" "DisableBatching" = "False"}

image

And add this line to MixedRealityStandardShaderGUI.cs: material.SetOverrideTag("DisableBatching", ScaleRequired() ? "True" : "False");

image

If this fixed the issue you are observing, then we can make this change in the toolkit. 😊

Cameron-Micka avatar Oct 12 '22 22:10 Cameron-Micka

We appreciate your feedback and thank you for reporting this issue.

Microsoft Mixed Reality Toolkit version 2 (MRTK2) is currently in limited support. This means that Microsoft is only fixing high priority security issues. Unfortunately, this issue does not meet the necessary priority and will be closed. If you strongly feel that this issue deserves more attention, please open a new issue and explain why it is important.

Microsoft recommends that all new HoloLens 2 Unity applications use MRTK3 instead of MRTK2.

Please note that MRTK3 was released in August 2023. It features an all new architecture for developing rich mixed reality experiences and has a minimum requirement of Unity 2021.3 LTS. For more information about MRTK3, please visithttps://www.mixedrealitytoolkit.org.

Thank you for your continued support of the Mixed Reality Toolkit!

IssueSyncBot avatar Jan 13 '24 00:01 IssueSyncBot