Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instanced Color on Standard Shader causes Visual Artifacts on Device #4188

Closed
mgrman opened this issue May 6, 2019 · 9 comments
Closed

Instanced Color on Standard Shader causes Visual Artifacts on Device #4188

mgrman opened this issue May 6, 2019 · 9 comments

Comments

@mgrman
Copy link

mgrman commented May 6, 2019

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:

  1. In PressableButtonPlated prefab, in the Material on BackPlate GameObject enabled Instanced Color (close to the bottom in the inspector).
  2. Deploy to device
  3. 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
@mgrman mgrman added the Bug label May 6, 2019
@dconleyMSFT dconleyMSFT added the ISV label May 6, 2019
@Cameron-Micka
Copy link
Member

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?

@mgrman
Copy link
Author

mgrman commented May 6, 2019 via email

@Cameron-Micka
Copy link
Member

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?

@Troy-Ferrell
Copy link
Contributor

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

@Cameron-Micka
Copy link
Member

I was able to get more context on this, this has already been addressed with #4049

@Rinatsin
Copy link

Rinatsin commented Jul 2, 2021

Добрый день. У меня возникла та же проблема с мерцанием после установки 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

Хотя в шейдере и материале исходном визуально я вижу что это поле есть.

@Rinatsin
Copy link

Rinatsin commented Jul 2, 2021

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).

@Cameron-Micka
Copy link
Member

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").

@Rinatsin
Copy link

Rinatsin commented Jul 5, 2021

Thank you, Cameron. I corrected the name of the property in the file to _Color, since you say that it should be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants