- Home /
How do I get the native texture pointer to a camera's depth texture?
I need to use the depth texture in a native plugin. Although I can make a camera generate a depth texture, the only way I have found to access this is using a Unity-side shader with:
sampler2D _CameraDepthTexture;
But my shaders are in the native plugin. How can I get a texture that I can send either as a texture or SRV pointer to C++?
The plugin is intended to be DX11-only in the first instance but a more general answer would be good.
The only solution I have for now is to do a Unity-side Graphics.blit to copy the depth into a RenderTexture. But that could be quite inefficient.
Your answer
![](https://koobas.hobune.stream/wayback/20220613141422im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Shader working in scene mode, but not in game mode (depth texture issue?) 3 Answers
Shaders: How to ztest against specific layers? 1 Answer
Setting depth buffer per-fragment 2 Answers
Projecting a plane onto a sphere 2 Answers
How to convert world position of a pixel to a depth value? (shader) 0 Answers