Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Oculus basic hand shader glitch

Discussion in 'Shaders' started by wyrrhcyn, Feb 28, 2021.

  1. wyrrhcyn

    wyrrhcyn

    Joined:
    Dec 16, 2016
    Posts:
    3
    Hi, I am trying to setup Oculus/Hands_Transparent shader but when I increase Rim Power i have such a ugly glitch. Anyone know how to get rid of it? It is transparency problem I guess
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    10,219
    Just that. This is a pretty standard problem with transparency.

    The solution that Oculus themselves use for their own desktop applications is to use a two pass shader. Render the hands once only to depth, and render again with the transparent shader.

    You can read about the implementation they use for Unreal engine here:
    https://developer.oculus.com/blog/t...ering-in-real-time-applications/?locale=es_LA

    For Unity it can be done in a more straight forward way with a two pass shader. This technique is even covered in Unity's own documentation (though buried quite deep were few people see it). Scroll down to "Transparent shader with depth writes":
    https://docs.unity3d.com/Manual/SL-CullAndDepth.html

    The latest Oculus avatar shaders for Unity should have this implemented already, though the original oculus hand shader did not. Not sure if they're both included or not with the default package as I've never used any of the shaders Oculus provides.

    However it should be noted that on mobile the two pass technique is extremely expensive. Transparent materials that depth write are a much bigger performance impact than they are on desktop. For Falcon Age I had to remove the depth only pass as if the user's hands were visible in this "ghost" form we could not maintain the framerate even in simple scenes and with dynamic resolution implemented. So our ghost hands on Quest are using an additive shader with depth writes disabled.
     
    ElasticSea likes this.
unityunity