01-19-2024 01:43 PM
I want to use the Depth API to copy the depth image to a PNG file on Quest 3.
https://developer.oculus.com/documentation/unity/unity-depthapi/#depth-api
I'm modifying the Depth API sample:
https://github.com/oculus-samples/Unity-DepthAPI
I'm getting the RenderTexture from Util.GetEnvironmentDepthTextureId() and XRDisplaySubsystem.GetRenderTexture.RenderTexture. However, when I save the RenderTexture to a PNG image, the image is entirely gray. Each pixel color is CDCDCDCD. The image is 2000x2000.
My problem is very similar to this reddit thread:
I looked at the OpenXR Depth API Overview page and I noticed that it says:
"Depth maps should only be accessed between the xrBeginFrame and xrEndFrame calls"
https://developer.oculus.com/documentation/native/android/mobile-depth/#acquiring-depth-maps
The Unity Depth API page says:
"RenderTexture can then be used in rendering or in compute shaders."
Is this why Texture2D.ReadPixels() doesn't work? Because the RenderTexture is only usable between xrBeginFrame and xrEndFrame? How do I copy the RenderTexture to a texture that I can read and then save to a PNG file? I'm not familiar with Unity's rendering or compute shaders.
01-28-2024 10:48 AM
01-28-2024 10:49 AM