Instanced Color on Standard Shader causes Visual Artifacts on Device
Describe the bug
Turning on Instanced Color for back plates of the pressable buttons, to batch them, causes visual artefacts on device. Color flickers as the cursor moves over the buttons. Tested with PressableButtonPlated prefab.
To reproduce
Steps to reproduce the behavior:
- In PressableButtonPlated prefab, in the Material on BackPlate GameObject enabled Instanced Color (close to the bottom in the inspector).
- Deploy to device
- Color flickers as the cursor moves over the buttons.
Expected behavior
No visual artifacts, same as in Editor.
Screenshots
If applicable, add screenshots to help explain your problem.
Your Setup (please complete the following information)
- Unity Version 2019.1
- MRTK Version v2.0
Target Platform (please complete the following information)
- HoloLens 2
Thank you Martin for filing this! Are you using the Graphics.DrawMeshInstanced api (or something similar) to render the backplates? Or, how are you passing in the instanced color?
Nothing special, backplate is part of the scene. Only checked the checkbox in the material. Then the interactable Theme changes the color based on button state using materialBlock
Get Outlook for Androidhttps://aka.ms/ghei36
From: Cameron [email protected] Sent: Monday, May 6, 2019 1:37:05 PM To: Microsoft/MixedRealityToolkit-Unity Cc: Martin Grman; Author Subject: Re: [Microsoft/MixedRealityToolkit-Unity] Instanced Color on Standard Shader causes Visual Artifacts on Device (#4188)
Thank you Martin for filing this! Are you using the Graphics.DrawMeshInstanced api (or something similar) to render the backplates? Or, how are you passing in the instanced color?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2FMixedRealityToolkit-Unity%2Fissues%2F4188%23issuecomment-489767225&data=02%7C01%7C%7C9a15d14ed81b4d04868208d6d2629ac7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636927718271728186&sdata=njwlr0FBm8cmOcQmOYh80qINa4dzT%2Fx%2BzCUk99%2B2B4o%3D&reserved=0, or mute the threadhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABOBMJMIIMISNKYLOMP7D43PUCJHDANCNFSM4HLDBVVQ&data=02%7C01%7C%7C9a15d14ed81b4d04868208d6d2629ac7%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636927718271738197&sdata=7Gt4CPXcyfl3Oh7dAQxtcXRWGQtmYP%2BE4yJ8Y9NQrq4%3D&reserved=0.
Ah okay! When the “instanced color” checkbox is checked the shader assumes a buffer of instanced color properties exists. If one doesn’t exist (which one will not unless explicitly set) then it is probably reaching into uninitialized, or neighboring, memory hence the flickering colors. I’m hoping to open source an example of using this feature soon, but I can send you the example early if you would like?
I think this is a bug we may have seen earlier Cameron whereby during initialization the material property is accessed causing a new instance to be created when that shouldn't be the case because the InteractableShaderTheme should be setting values via materialblocks
I was able to get more context on this, this has already been addressed with https://github.com/microsoft/MixedRealityToolkit-Unity/pull/4049
Добрый день. У меня возникла та же проблема с мерцанием после установки GPU Instance на материале. Хотя скрипт стоит уже исправленный. Я делаю меню с компонентом Scrollig Objects, скрипт вешает на префаб меню , компонент MaterialInstance. И возникает ошибка
ArgumentException: Could not find MaterialProperty: '_InstancedColor', Num properties: 96 UnityEditor.ShaderGUI.FindProperty (System.String propertyName, UnityEditor.MaterialProperty[] properties, System.Boolean
Хотя в шейдере и материале исходном визуально я вижу что это поле есть.
And further . Of course, I'm not very good at shaders, but as far as I understand, the UNITY_INSTANCING_BUFFER_START (Props) block should be implemented in the shader. The standard shader has this block, but it does not implement the _InstancedColor property (there is only _Color).
Hi @Rinatsin, that you for reporting this. You are correct the MRTK/Standard shader's instanced color property is named _Color and not _InstancedColor which you can see here.
Do you know where the exception you posted above is coming from, or can you post the whole call stack? If it's coming from MRTK code it should be easy enough to change the FindProperty call from FindProperty("_InstancedColor") to FindProperty("_Color").
Thank you, Cameron. I corrected the name of the property in the file to _Color, since you say that it should be.