ViveSoftware / ViveInputUtility-Unity

A toolkit that helps developing/prototyping VR apps.
http://u3d.as/uF7
Other
358 stars 81 forks source link

Override shader logic, doesn't over ride controller model shaders #193

Open wirelessdreamer opened 4 years ago

wirelessdreamer commented 4 years ago

Using URP, controllers are currently pink, even after overriding the shader on render model hook script:

image image image image

Expected behavior when over riding shaders, is that they are overridden :)

chengnay commented 4 years ago

@wirelessdreamer Could you help to verify below solution? Thanks!

Under folder "Assets\HTC.UnityPlugin\ViveInputUtility\Scripts\Misc\OculusVRExtension\" in VIUOculusVRRenderModel.cs file, Line 620, var shader = m_shaderOverride == null ? Shader.Find("OvrAvatar/AvatarSurfaceShaderPBS") : m_shaderOverride;

Line 644, var shader = m_shaderOverride == null ? Shader.Find("OvrAvatar/AvatarPBRV2Simple") : m_shaderOverride;

By the way, how did you get the "Universal Render Pipeline/Lit" shader? I only can manually select "URP/Lit" shader in SkinnedMeshRenderer script. image

wirelessdreamer commented 4 years ago

Those updates turn the shader from pink to grey, so half way there. I now get this error: image

So it looks like SetTexture is already used: image

I changed from "_Surface" to "_BaseMap" and the error went away, its still grey though.

My guess of how I get Univeral Render Pipeline/Lit as an option is i'm in unity 2019.4.8.f1 its just there as an option.

chengnay commented 4 years ago

@wirelessdreamer Are you using Universal RP 7.3.1 or 7.5.1?

wirelessdreamer commented 4 years ago

7.3.1

On Tue, Sep 15, 2020 at 10:52 PM ChengNan Yang notifications@github.com wrote:

@wirelessdreamer https://github.com/wirelessdreamer Are you using Universal RP 7.3.1 or 7.5.1?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ViveSoftware/ViveInputUtility-Unity/issues/193#issuecomment-693138267, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABCHPKNMA5I2H2LHQUULO3SGAR6NANCNFSM4RHQVZAQ .

chengnay commented 4 years ago

@wirelessdreamer You mentioned the color is grey, so you think it should be other color instead of grey?

I replaced the shader (Univeral Render Pipeline/Lit) manually and it is also grey. image

wirelessdreamer commented 4 years ago

I thought I remembered the vive controller showing up as black, so I wasn't sure why the rift controller showed up a different color.

On Tue, Sep 15, 2020 at 11:47 PM ChengNan Yang notifications@github.com wrote:

@wirelessdreamer https://github.com/wirelessdreamer You mentioned the color is grey, so you think it should be other color instead of grey?

I replaced the shader (Univeral Render Pipeline/Lit) manually and it is also grey. [image: image] https://user-images.githubusercontent.com/33050705/93290027-5d802380-f812-11ea-94ca-d61e1e361d9b.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ViveSoftware/ViveInputUtility-Unity/issues/193#issuecomment-693152372, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABCHPP3VMPYOEVGLE7MVK3SGAYNLANCNFSM4RHQVZAQ .

chengnay commented 4 years ago

@wirelessdreamer Black is the default shader provided by the SDK, if I replace the VIU's default controller model(White) with Universal Render Pipeline/Lit shader it looks just like the one I posted above.

EDIT: After I use VIU's recommended settings for Oculus Desktop, the color of controller model changes to White. image

chengnay commented 4 years ago

I changed from "_Surface" to "_BaseMap" and the error went away, its still grey though.

Could you help to try below code?

if (m_shaderOverride == null) { mesh.sharedMaterial.SetTexture("_Surface", OvrAvatarComponent.GetLoadedTexture(surfaceTextureID)); }

"_Surface" was copied from Oculus SDK, will it matter if skip this part when there is override shader? I still cannot see "Universal Render Pipeline/Lit" on my Unity Editor after I try to add it to Override Shader in Render Model Hook.

EDIT: I found it under folder "Packages/UniversalRP/Shaders/". I will double check again whether "_Surface" is required or not.

chengnay commented 4 years ago

I guess "_Surface" is a customized shader property by Oculus, that's why when loading URP/Lit and it will show that error. https://answers.unity.com/questions/1169367/how-to-get-the-property-names-from-shader-in-runti.html

I will resolve this in next release.

chengnay commented 4 years ago

@wirelessdreamer Please try below solution if it works on your side.

if ((mesh.sharedMaterial.GetTexture("_Surface") != null)) { mesh.sharedMaterial.SetTexture("_Surface", OvrAvatarComponent.GetLoadedTexture(surfaceTextureID)); }

On my side, it works without printing the error message.

If this solution works, I will also include the previous solution(Override Shader).

wirelessdreamer commented 4 years ago

changing back from __BaseMap to the above code segment gives this error spamming

image

chengnay commented 4 years ago

@wirelessdreamer I can only think of getting the GetPropertyCount of shader to differentiate between Oculus's and URP's.

if (mesh.sharedMaterial.shader.GetPropertyCount() == 3) { mesh.sharedMaterial.SetTexture("_Surface", OvrAvatarComponent.GetLoadedTexture(surfaceTextureID)); }

I am still looking for better solution and I will need to verify with Oculus Quest and also Oculus Rift S.

chengnay commented 4 years ago

@wirelessdreamer Did you try the solution yet? I double check the solution with Oculus Rift S, Link Quest and Quest, no errors found.

wirelessdreamer commented 4 years ago

I think this is what you wanted tested:

image

Its still grey, and not black after that.

chengnay commented 4 years ago

@wirelessdreamer Did you accept all for VIU's recommended settings for Oculus Desktop? By looking into the details of URP/Lit shader, it is white or maybe a bit greyish(after I accept all for recommended settings, it turns to white as I last posted image above). image

Unless you will have to manually edit the color by yourself.

If you still have concern about the color of the controllers, please share a sample project for further investigation, thanks!

wirelessdreamer commented 4 years ago

What about adding a Color over ride to Render Model Hook, just like there is a shader override: image

chengnay commented 4 years ago

@wirelessdreamer I will need to discuss this internally or provide you with sample code. Sorry for the inconvenience.

lawwong commented 4 years ago

How about adding override material?