Forum Discussion

pon7's avatar
pon7
Protege
5 months ago

How to occlude objects at a far distance?

I have a big virtual environment with some pillars.  Currently, the AR objects are being rendered over the pillars.  I would like a way to occlude the objects where the physical pillars are so that the virtual objects appear to be behind the pillars.

In the HoloLens and Magic Leap, I would simply include the virtual pillars and put a matte black material on them.  The headset would render the black objects (the virtual pillars) as passthrough, and occlude any virtual object behind them, thereby making the virtual objects appear to be behind the physical pillars.

How do I do something similar with the Quest 3?  When I research this topic, the solution seems to be use Depth API, but my virtual environment is much too large for that solution.  How do I get a virtual object to appear behind a physical object that is far away? 

Thanks.

6 Replies

  • Hello there!

    If you go to the Mixed Reality Utility Kit, you may use the Space Setup feature which allows users to generate a Scene Model. This gives you the ability to have a good amount of control over your scene, such as the occlusion of objects. 

    If you go here, it will take you to our passthrough windows tutorial. You may be able to use these windows to cut out the pillars to sit in front of your AR objects. This is more so if the majority of your environment will be virtual.

    If neither of these helped, let me know so we may find an alternate solution!

    • pon7's avatar
      pon7
      Protege

      I kept digging and found the PokeAHoleMaterial.  I definitely think this is the way to go as it seems exactly like how the HoloLens and Magic Leap do it.  But when I apply the PokeAHoleMaterial onto my objects, they just render black.  I'm going to circle back to this in a couple days and try again but if you have any points as to why PokeAHole is rendering black, I'd appreciate it.  Thanks.

      • GATORSAURU5's avatar
        GATORSAURU5
        Meta Employee

        Here is our document on troubleshooting passthrough, switching to Vulkan preview mode may resolve this issue. If this does fix the mesh rendering black, let me know!

    • jtriveri's avatar
      jtriveri
      Start Partner

      Expanding on this: applying an opaque shader with a 0 alpha value to an object will make passthrough appear under that object. This is because Quest uses the eye buffer's (what you see) alpha channel to composite passthrough under your application. A shader doesn't need to be transparent/alpha blended to have an alpha value of 0. You just need to know where the column is to put an object with this shader there, and this could be done with the room scan mesh. 

      This shader from the core SDK should do the trick: EDIT oops I always assume people use Unity :(

      Shader "Punch Through Passthrough"
      {
          Properties
          {
              _MainTex ("Texture", 2D) = "white" {}
          }
          SubShader
          {
              Tags {"Queue" = "Geometry"}
              ZWrite On
              Cull Off
              ZTest Always
      
              Blend Zero Zero
      
              Pass
              {
                  CGPROGRAM
                  #pragma vertex vert
                  #pragma fragment frag
      
                  #include "UnityCG.cginc"
      
                  struct appdata
                  {
                      float4 vertex : POSITION;
                      float2 uv : TEXCOORD0;
                  };
      
                  struct v2f
                  {
                      float2 uv : TEXCOORD0;
                      float4 vertex : SV_POSITION;
                  };
      
                  sampler2D _MainTex;
                  float4 _MainTex_ST;
      
                  v2f vert (appdata v)
                  {
                      v2f o;
                      o.vertex = UnityObjectToClipPos(v.vertex);
                      o.uv = v.uv;
                      return o;
                  }
      
                  fixed4 frag (v2f i) : SV_Target
                  {
                      return fixed4(0, 0, 0, 0);
                  }
                  ENDCG
              }
          }
      }



      • pon7's avatar
        pon7
        Protege

        Thanks for the reply.  I tried making an opaque material with an alpha channel set to 0.  Tried both Lit and Unlit.  Neither worked.  Maybe I'm doing something wrong?

         

→ Find helpful resources to begin your development journey in Getting Started

→ Get the latest information about HorizonOS development in News & Announcements.

→ Access Start program mentor videos and share knowledge, tutorials, and videos in Community Resources.

→ Get support or provide help in Questions & Discussions.

→ Show off your work in What I’m Building to get feedback and find playtesters.

→ Looking for documentation?  Developer Docs

→ Looking for account support?  Support Center

→ Looking for the previous forum?  Forum Archive

→ Looking to join the Start program? Apply here.

 

Recent Discussions