But for this i need the linear depth [0…1]. But it looks like the depth unity is providing isn’t linear. I already tried Linear01Depth but this just outputs black. is there a better way to reconstruct view space position in unity instead of using my method which needs linear depth?
Not entirely sure whether this is the same thing or whether it will help, but it seems to draw the depth if you place the shader on an object. However, it uses:
camera.depthTextureMode = DepthTextureMode.Depth;
The depth it gets in the fragment shader should be linear. Although, make sure your scale of the scene is not really small as I think the depth value is based on the camera’s clipping planes so scene with really small scale would render a lot of black.