Forum Discussion
GTD-Carthage
1 year agoHonored Guest
[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
}
Replies have been turned off for this discussion
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 months ago
- 10 months ago