microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

MRTK Shader for URP does not use Environment Lighting #10172

Closed markfrede closed 9 months ago

markfrede commented 3 years ago

Describe the bug

The MRTK Shader when upgraded to work with Universal Render Pipeline (URP) is not affected by the Environment Lighting (Skybox, Gradient, and Color).

To reproduce

Steps to reproduce the behavior:

  1. Create a Unity project with MRTK and the URP packages.
  2. Apply the MRTK standard shader to a new material and apply that material to an object.
  3. Adjust the environment lighting by going to the light tab, choosing the environment tab within the lighting tab, and then changing the Environment lighting source from skybox to color and adjust the color to an extreme color to clearly see the effect in the viewport. You should see the material take on the ambient color.
  4. Create and apply a pipeline asset to the graphics tab in the project settings, switching the project to use the Universal Render Pipeline rather than the Built-in pipeline. This will break the MRTK material.
  5. Upgrade the MRTK standard shader by going to the Mixed Reality menu, then Toolkit, then Utilities, and lastly select "Upgrade MRTK Standard Shader for Universal Render Pipeline". This should fix the shader error.
  6. The material may look like it is still affected by the Environment Lighting settings however adjusting the Ambient Color will have no effect. Upon restarting the project the object will no longer be affected by the Environment Lighting settings. The object will however be temporarily affected if the pipeline asset is removed and re-added to the Scriptable Render Pipeline Settings.

Expected behavior

Adjusting the ambient color should affect objects using MRTK Standard Shader materials once the project is using URP.

NOTE: Turning on the "Spherical Harmonics" property in the material does make the environment lighting settings affect the object however this setting is not always desired and it does not mimic the behavior of the shader before it is upgraded to work with URP.

Screenshots

MRTK_URP_Bug_Screen1 MRTK_URP_Bug_Screen2 MRTK_URP_Bug_Screen3 MRTK_URP_Bug_Screen4

Your setup (please complete the following information)

Target platform (please complete the following information)

Additional context

The screenshots I've provided showcase the behavior I'm experiencing using 4 spheres with 4 separate materials (and shaders). The shaders are from left to right: Standard Shader (Built-in Pipeline), MRTK Standard Shader (Built-in Pipeline), MRTK Standard Shader (URP upgraded shader), and the Simple Lit Shader (URP). In order, the screenshots show how the ambient color changes affect the materials as the project gets upgraded to URP.

WikkidEdd commented 3 years ago

@markfrede I think you'd find that even using the Built-in Pipeline and the MRTK you wouldn't get true environment lighting (skybox as opposed to an single ambient color) without Spherical Harmonics.

When you don't have that ticked it falls back to a very old shader constant "glstate_lightmodel_ambient" which can only ever give you a single ambient color in Built-in Pipeline and doesn't get populated at all in URP which is why you see the discrepancy

stale[bot] commented 2 years ago

This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.

IssueSyncBot commented 9 months ago

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!