DepthAPI Occlusion Lit conflict with stencil shader
Hi there, I'm currently working on creating a local multiplayer XR experience that involves both portal effects (using a custom stencil shader) and DepthAPI to allow players to see each other in a shared space.I've managed to get DepthAPI and the stencil shader to work individually, but I can't figure out how to combine them. The main issue is that DepthAPI, which uses the depth sensor of the Meta Quest 3, recognizes physical walls around players and prevents pixels of objects that are virtually further from the headset than the walls from being drawn. So, while the portal stencil works, it can't render the "outside" of the room. Do you have any ideas on how to deal with this? I'm not skilled enough in shaders to resolve it on my own. Here some screenshots of my current progress :2.2KViews0likes8Comments[Resolved] DepthAPI depth texture as Scene Depth style Shader Graph node
Hey, folks! I am not exactly HLSL-inclined, is there a way to reference the depth texture produced by DepthAPI in a way similar to the Scene Depth node for Shader Graph? We are attempting to use it directly for certain shader visuals rather than just the final occlusion too. -- Question is resolved! I've received a response from the DepthAPI team - the following is the Custom Function code snippet for Shader Graph: #pragma warning (disable : 3568) #pragma multi_compile _ HARD_OCCLUSION SOFT_OCCLUSION #ifndef SHADERGRAPH_PREVIEW #include "Packages/com.meta.xr.sdk.core/Shaders/EnvironmentDepth/URP/EnvironmentOcclusionURP.hlsl" #endif void GetEnvironmentSceneDepth_float(float3 posWorld, out float environmentDepth) { #ifndef SHADERGRAPH_PREVIEW const float4 depthSpace = mul(_EnvironmentDepthReprojectionMatrices[unity_StereoEyeIndex], float4(posWorld, 1.0)); const float2 uvCoords = (depthSpace.xy / depthSpace.w + 1.0f) * 0.5f; environmentDepth = SampleEnvironmentDepthLinear(uvCoords); #else environmentDepth = 0; #endif } void GetEnvironmentSceneDepth_half(float3 posWorld, out float environmentDepth) { #ifndef SHADERGRAPH_PREVIEW const float4 depthSpace = mul(_EnvironmentDepthReprojectionMatrices[unity_StereoEyeIndex], float4(posWorld, 1.0)); const float2 uvCoords = (depthSpace.xy / depthSpace.w + 1.0f) * 0.5f; environmentDepth = SampleEnvironmentDepthLinear(uvCoords); #else environmentDepth = 0; #endif }734Views0likes0Comments