Closed Ericcsr closed 4 months ago
Hey,
You should be able to do this, yes. I've never done this myself. You could try to get the texture directly from xrDisplay, like we do it in DepthTextureProvider. There's a TryDepthTexture function there that does this. As far as writing it to disk, this doesn't seem relevant to this API, specifically, though. I'll leave this thread open, for now, in case someone else wants to chime in.
I can get the depth map and save it locally now, the main issue I encountered is setting RenderTexture.active = DepthTexture will not work on VR. My solution uses a compute shader from: https://github.com/Orinion/RaycastTest/tree/main
to save all the depth values I needed locally.
I can get the depth map and save it locally now, the main issue I encountered is setting RenderTexture.active = DepthTexture will not work on VR. My solution uses a compute shader from:
https://github.com/Orinion/RaycastTest/tree/main
to save all the depth values I needed locally.
Hi! Recently, I also wanna obtain depth maps from Quest 3. Could you share the valuable codes? Thank you very much!
Closing due to inactivity.
I was trying to save depth texture obtained from DepthTextureProvider as jpg images. Here is what I did:
RenderTexture.active = depthTexture
.Texture2D
and callReadPixels
withRect
.However, the image I got is either black or white, while I can visualize depth image in Quest.
Here is the script I use: `using UnityEngine; using UnityEngine.UI; using Meta.XR.Depth; using TMPro; using UnityEditor; using System.IO;
namespace SolerSoft.Customization { ///
/// Renders a Meta depth map into Unity UI
///
public class RenderDepthMap : MonoBehaviour
{
// #region Constants
// private static readonly int VirtualDepthTextureID = Shader.PropertyToID("_CameraDepthTexture");
// #endregion // Constants
// Define some variables for program
region Private Variables
}`