I’m trying to render a scene as a depth map, for export into another process (generating autostereograms, in case you’re curious). But I’m struggling to get Unity to do this. Here’s what I’ve tried:
- Added a script to the camera which, in Start, does
GetComponent<Camera>().depthTextureMode = DepthTextureMode.Depth;
This results in a little note appearing at the bottom of the Camera inspector:
“Info: renders Depth texture”. Sounds promising! And you can see I have set the Target Texture to a RenderTexture I created in the project.
But the result is not a depth map. The contents of my RenderTexture are an ordinary full rendering, including colors, lights, and shadows. Clearly I’ve missed some vital step.
Anybody know how to make this work? Or, is there an easier way to generate a depth map for a Unity scene?
