accessing depth information of rendertexture

Hey,

I can create a RenderTexture and have the cam render into it.

depth = new RenderTexture(Width, Height, 16);

i have specified a depth buffer of 16 bit. How can I access the depth values of this 16 bit depth buffer via scripting?

(i need both color and depth values, if possible with only one draw call)

I’m going to resurrect this post since I have the same question, and think the original commentor didn’t quite understand the question.

I know a render texture is a texture that you can render to instead of the frame buffer. You can treat that texture the same as any other texture. This means it’s a Texture2D and it can be bound to a 2D texture property to be used in a shader.

The OP is asking where the Depth Texture2D is. I did some OpenGL programming a long time ago and thought that you could access the depth buffer somehow, or maybe it’s just an option you pass into the binding statement that enables the z buffer for when the colors are drawn, and that’s it. After that it’s gone. Is that the case, or can the depth values be accessed like the colors in a render texture?

Thanks :slight_smile: