Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums will be revoked at the discretion of Oculus staff.
New to the forums? Click here to read the How To guide. -- Developers click here.

Avatar Hands sorting oddly with transparent objects (TextMeshPro) in Unity.

beppert-clbeppert-cl Posts: 7 Oculus Start Member
Transparent objects that should appear in front of the hands getting clipped. Trying to use TextMeshPro but same issue on any transparent material. Saw it in Unity 5.6.4 have since upgraded to Unity 2017.3.1 same issue. Oculus Utilities/Avatar 1.24. 

Opaque works, Cutout also works but not useable due to harsh edges. The only thing close that works is a shader from SteamVR - Valve/VR/Silhouette (pictured as a circle) but isn't usable as a font shader.


Comments

  • imperativityimperativity Posts: 3,587 Valuable Player
    Hi,

    Are you familiar with our OVROverlay script?

    From the docs on the above:

    Ordering and Transparency

    The depth ordering of compositor layers is controlled by two factors:

    1. Whether objects are rendered in front of or behind the scene geometry rendered to the eye buffer, and
    2. The sequence in which the compositor layers are enabled in the scene.

    By default, VR compositor layers are displayed as overlays in front of the eye buffer. To place them behind the eye buffer, set Current Overlay Type to Underlay in the Inspector. Note that underlay compositor layers are more bandwidth-intensive, as the compositor must “punch a hole” in the eye buffer with an alpha mask so that underlays are visible. Texture bandwidth is often a VR bottleneck, so use them with caution and be sure to assess their impact on your application.

    Underlays depend on the alpha channel of the render target. If a scene object that should occlude an underlay is opaque, set its alpha to 1. If the occluder is transparent, you must use the OVRUnderlayTransparentOccluder shader provided in the Utilities in Assets/OVR/Shaders. Overlays do not require any special handling for transparency.

    Compositor layers are depth ordered by the sequence in which they are enabled in the scene, but the order is reversed for overlays and underlays. Underlays should be enabled in the scene in the sequence in which you want them to appear, enabling the underlays in front first and the layers in the back last. Overlays should be enabled in the opposite order.

    Basic usage

    1. Attach OVROverlay.cs to a Game Object.
    2. Specify the Current Overlay Shape:
      • Quad (Rift and Mobile)
      • Cubemap (Rift and Mobile)
      • Cylinder (Mobile only)
    3. Specify the OVROverlay Texture. If you leave it as None (default), it will use the Renderer material’s main texture, if available. See OVRRTOverlayConnector below for more information on rendering textures to an OVROverlay Game Object.
    4. Disable all compositor layers (both overlays and underlays),
    5. Enable them sequentially to set the order in which you wish them to appear, enabling overlays in front last and underlays in front first.



  • beppert-clbeppert-cl Posts: 7 Oculus Start Member
    edited April 2018
    No I hadn't, I can try this. Thanks,
  • beppert-clbeppert-cl Posts: 7 Oculus Start Member
    @imperativity - I was not able to use the OVROverlay components because it selects a static texture but the TextMeshPro Unity package "texture" is a font atlas and the text is generated in realtime by the shader. Did I miss something?

    I did have success with an alternative solution based on another forum post: https://forums.oculusvr.com/developer/discussion/comment/491844/#Comment_491844

    Copied the TMP_SDF shader from the TextMeshPro package and modified the SubShader section to:

        Tags
        {
            "Queue" = "Geometry+10000"
            "RenderType"="Outline"
            "RenderType" = "Transparent"
        }
            Blend One OneMinusSrcAlpha

    which seems to work for transparent text either in front or behind the Avatar hands.



  • beppert-clbeppert-cl Posts: 7 Oculus Start Member
    @imperativity - I was not able to use the OVROverlay components because it selects a static texture but the TextMeshPro Unity package "texture" is a font atlas and the text is generated in realtime by the shader. Did I miss something?

    I did have success with an alternative solution based on another forum post: https://forums.oculusvr.com/developer/discussion/comment/491844/#Comment_491844

    Copied the TMP_SDF shader from the TextMeshPro package and modified the SubShader section to:

        Tags
        {
            "Queue" = "Geometry+10000"
            "RenderType"="Outline"
            "RenderType" = "Transparent"
        }
            Blend One OneMinusSrcAlpha

    which seems to work for transparent text either in front or behind the Avatar hands.



  • digibixdigibix Posts: 17 Oculus Start Member
    Try this on the TextmeshPro object:
    • Go to the Textmeshpro script section
    • Click on Extra Settings...(to open the extra options)
    • On the sorting layer row change the order to 10
  • beppert-clbeppert-cl Posts: 7 Oculus Start Member
    digibix said:
    Try this on the TextmeshPro object:
    • Go to the Textmeshpro script section
    • Click on Extra Settings...(to open the extra options)
    • On the sorting layer row change the order to 10

    This worked too, after changing the "Sorting Layer" from "Default" to "MetaCanvas". Thanks @digibix it's a better solution as it doesn't require maintaining a parallel shader for TextMeshPro.
Sign In or Register to comment.