I’m fairly new to Unity and I’m trying to make a script to get all depth values for each pixel in my Unity scene, or in my camera’s view and output them to a file for post processing. I’ve looked at quite a bit of links trying to do this but found nothing so far. Some people have mentioned creating custom shaders or using Depth Textures (Unity - Manual: Cameras and depth textures), but those didn’t seem to do the trick. If someone could point me in the right direction or tell me if this is even possible to do would be much appreciated. Thanks!
Yeah using a shader to give you the depth value via GetPixels is what I do. Unfortunately, the shader code in that link doesn’t appear to work (I tried it myself and it didn’t work for me). I’ve bugged Unity to update their docs with a working version, but that hasn’t happened yet, it seems.
This tutorial worked for me last time I used it (back on Unity 5.3… although it should probably still work): http://willychyr.com/2013/11/unity-shaders-depth-and-normal-textures/
1 Like
Thanks! I’ll give it a try and see how it goes. I’ll re-update the post if I do get it working too