- Home /
Question by
diabloIM · Oct 09, 2016 at 09:12 AM ·
shaderrendertexturedepth-buffer
Accessing rendertexture depthbuffer using shader
I have a RenderTexture which I modify from a native plugin using GetNativeTexturePtr(), this is working perfectly. Now I want to write a shader that accesses the depthbuffer of RenderTexture, and creates a 3D effect based on that.
My idea is to pass the depth buffer to native plugin using GetNativeDepthBufferPtr(), modify it from there, and then use the values in shader to create a 3D effect. By 3D effect I mean suppose the depth value for (x, y) is 0x0000, the pixel will be closest and 0xFFFF means the pixel will be farthest.
Is this possible? Or have I completely misunderstood how depth buffers are used?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612094305im_/https://answers.unity.com/themes/thub/images/avi.jpg)