Jump to content

Vive Focus 3, Unity and URP pink shaders (shader variants not being compiled during build)


ett

Recommended Posts

Hi all,

I'm having issues getting the wave sdk to work with Unity. Details are as follows:

When I run the application on the Focus 3 all materials are pink. The shaders have not been found 😭

I'm using the following

Unity Version: 2020.3.17f1 (LTS)

"com.unity.xr.management""4.0.7",
"com.htc.upm.wave.essence""4.1.1-r.3.1",
"com.unity.render-pipelines.universal""10.6.0",
 
Basically the issue/repro steps are as follows:
 
  • Create new URP project, use the default scene in the build.
  • Switch to Android platform, add OpenGL, remove Vulkan (may take some time)
    • Try and build an .apk, observe that shader variants are compiled for build (cancel, before they all compile)
  • Package manager -> install com.unity.xr.management
    • Try and build an .apk, observe that shader variants are compiled for build (cancel, before they all compile)
  • Add 
    "scopedRegistries": [
        {
          "name""VIVE",
          "url""https://npm-registry.vive.com/",
          "scopes": [
            "com.htc.upm"
          ]
        }
      ]
    to packages manifest, enable Preview Packages and install com.htc.upm.wave.essence via package manager
  • Visit Project settings, XR Plug-in Management (at the bottom),  and enable WaveXR under android Plug-in providers
  • Agree to all settings suggested by WaveXRPlayerSettingsConfigDialogue (found via ProjectSettings, Wave XR, playersettings configure dialogue button)
  • Perhaps convert main camera to an XR rig, not sure how important that is.
  • Try and build an .apk, observe that shader variants are NOT compiled for build.
    • If you run this build on the device you should observe that all materials are pink. 
  • Return to Project Settings, XR Plug-in Management (at the bottom),  and disable WaveXR and enable Oculus under android Plug-in providers
    • Try and build an .apk, observe that shader variants are compiled for build (cancel, before they all compile)
 
For me it seems that URP shaders just don't get compiled for some reason when using the wave sdk. They do when using the Oculus sdk. I have no idea why.
I tried adding a shader variant collection tracking the URP lit shader variants etc, shoved it in a resources folder and even referenced it in a scene. Still no shader variant compilation during build.
 
Any suggestions would be much appreciated!
 
Link to comment
Share on other sites

Have set up everything on a colleague's machine and it works perfectly for them.

I completely uninstalled and reinstalled Unity and so on but afterwards I still get the same issue. Just re-importing the library folder now to see if that will fix it. Otherwise I must assume that something is very wrong with my machine, but I have no idea what. It still only refuses to compile shader variants when deploying with Wave XR checked in the XR Plug-in Management part of settings.

This could be related to the following issue as it seems pretty similar:

 

Link to comment
Share on other sites

Hi all,

This actually turned out to be a bug with the Wave SDK and an issue with my inability to not click everything.

There is an option called Enable Shader Stripping that I must have clicked at some point that was causing the issue.

image.png.84a603a4a8935061b2772b6caa3f2185.png

The problem is that the Wave SDK logic is not coded correctly for URP.

Let's take a look at the code below for this option (ShaderStripping.cs). If we click this button the second function will run and set the Editor Preference to true, yes please strip the shaders.
But then the validation function runs (the first one) which prints a message saying "Wave Essence Shader Stripping: Current Rendering Pipeline not supported." and setting the menu to show false.

Can you see the bug? The menu entry indicates the option is not enabled but the underlying editor preference boolean value is still set to true.

		[MenuItem(MenuItem, true)]
		private static bool SetShaderStrippingVaildate()
		{
			isShaderStrippingEnabled = EditorPrefs.GetBool(EditorPrefEntry, false);


#if URP_INSTALLED

			if (GraphicsSettings.renderPipelineAsset != null)
			{
				isShaderStrippingEnabled = false;
				Debug.Log("Wave Essence Shader Stripping: Current Rendering Pipeline not supported.");
			}

#endif
			Menu.SetChecked(MenuItem, isShaderStrippingEnabled);

			return true;
		}

		[MenuItem(MenuItem, false, 2)]
		private static void SetShaderStripping()
		{
			isShaderStrippingEnabled = !isShaderStrippingEnabled;
			Menu.SetChecked(MenuItem, isShaderStrippingEnabled);
			EditorPrefs.SetBool(EditorPrefEntry, isShaderStrippingEnabled);
			Debug.Log($"Shader stripping {EditorPrefs.GetBool(EditorPrefEntry, false)}");
		}

 

What this means is that when I was building for URP the ShaderStrippingBuildProcessor was still activating and stopping shader variants being compiled.

Now the bigger issue with this is that it uses EditorPrefs for storing this value, which means it goes in the registry on Windows. Which means it survives Unity uninstalls/re-installs, project re-imports, basically everything you would normally do to deal with it. This explains why it was an issue for me but not a colleague's fresh machine.
The value is actually stored in the Windows registry at Computer\HKEY_CURRENT_USER\Software\Unity Technologies\Unity Editor 5.x

image.png.9315bd9369bc52cad28bee6697a765f3.png

 

The fix is pretty simple. Hit the menu entry again and it should toggle the value.
However a better fix that does deal with the issue as intended is simply modifying ShaderStripping.cs:

#if URP_INSTALLED

			if (GraphicsSettings.renderPipelineAsset != null)
			{
				isShaderStrippingEnabled = false;
  				EditorPrefs.SetBool(EditorPrefEntry, isShaderStrippingEnabled); // I am new and solve all your problems :)
				Debug.Log("Wave Essence Shader Stripping: Current Rendering Pipeline not supported.");
			}

#endif

 

Hope this helps someone else. Only took me 2 days of project re-imports and Unity installations.

Best  (☞゚ヮ°)☞

Edited by ett
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...