MixedReality-GraphicsTools-Unity icon indicating copy to clipboard operation
MixedReality-GraphicsTools-Unity copied to clipboard

MRTK URP support for Unity 2021.3.29+ (URP 12.1.12+)

Open paulio opened this issue 2 years ago • 10 comments

MRTK URP support for Unity 2021 (URP 12.1.12+)

Installing MRTK in a Unity 2021 project that is using URP incorrectly produces invisible materials. When the MRTK Standard opaque shader is applied the material is incorrectly invisible. The problem is not seen in Unity 2020 projects. The problem occurs for both MRTK v2 and v3.

To reproduce

Steps to reproduce the behavior:

  1. Create an Unity 2021 project using the URP (3D) Template
  2. Using the MRTK feature tool add the standard set of assets and the Shader examples.
  3. Use the MRTK Upgrade URP Materials tool menu (if using v2)
  4. Once the install is complete view the Shader Material examples or create a new opaque material using the MRTK Standard shader
  5. Note that you cannot see the resulting material in either the preview or when the material is applied to a mesh (e.g. a simple cube)

Expected behavior

The Shader should display the color as stipulated in the shader settings

Screenshots

Expected (from Unity 2020) image

Unity 2021 MRTK 2 image

MRTK 3 image

Your setup (please complete the following information)

  • Unity Versions 2021.3.29f1 2020.3.42
  • MRTK Version MRTK2 2.8.3 MRKT3 3.0.0-pre18

Target platform

  • HoloLens 2, UWP

Additional context

Add any other context about the problem here.

paulio avatar Sep 06 '23 11:09 paulio

Thank you @paulio for the bug report, we will try and reproduce this. One quick question, do you see any shader compilation issues in the Standard shader's inspector? They would appear roughly here: image

Cameron-Micka avatar Sep 06 '23 17:09 Cameron-Micka

No, the only thing I noticed was something about it not being batch compatible which was further down that inspector

paulio avatar Sep 06 '23 17:09 paulio

Awesome, good to know. Also if you clone this repository and open the Unity project do you see the same issue? You can show the samples via Window > Graphics Tools > Show Samples in this repo's sample project.

Cameron-Micka avatar Sep 06 '23 18:09 Cameron-Micka

I can confirm the repro works... 0.6.1 image vs. Feature Tool Install Graphics Tools v0.5.12 image

paulio avatar Sep 06 '23 21:09 paulio

Now to understand why, and see if the fix is available (or can be applied to) MRTK2 too.

paulio avatar Sep 06 '23 22:09 paulio

Interesting! @shaynie you are more knowledgeable about the feature tool than I am - do you have any ideas?

Cameron-Micka avatar Sep 06 '23 22:09 Cameron-Micka

I compared the shaders and they seem exactly the same, apart from, maybe the dependency on the version of URP.

paulio avatar Sep 07 '23 08:09 paulio

Aha, it's something to do with the URP Pipeline Asset Renderer. I copied UniversalRenderPipelineAsset & UniversalRenderPipelineAsset_Render and set them as the default in Settings URP and Settings Quality. This seems to have fixed the issue.

paulio avatar Sep 07 '23 08:09 paulio

Found it... image Change needed is from Auto to Disabled

paulio avatar Sep 07 '23 09:09 paulio

Great catch @paulio! Sounds like we need to add extra passes to the shader to support this: https://forum.unity.com/threads/custom-shaders-make-mesh-invisible-in-urp-2021-3-22f1-solved.1422327/

Cameron-Micka avatar Sep 07 '23 16:09 Cameron-Micka