Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Saving depth images into an array

Discussion in 'General Graphics' started by fastcoder, Feb 14, 2019.

  1. fastcoder

    fastcoder

    Joined:
    Sep 20, 2013
    Posts:
    16
    I am working on an image based rendering project. Therefore I need to project real world captured images onto a 3D model, for which I have the poses of images already. However I don't have depth maps. So I must create depth maps in unity by rendering the model from that given list of poses (I have the correct camera parameters.) Therefore if a real world image doesn't observe some part of the scene it shouldn't be projected there.

    My problem is how do I create and save those depth/shadow textures so that I can later access during the actual visualization/rendering stage. Also, I need to access depth information from C# so that I can process 3D information using OpenCV etc.

    I already tried rendering depth information into rgba32 render texture using EncodeFloatRGBA in the shader. Then copied this texture into texture2D array. However, I need a texture in the array to be linearly interpolated during reading. As the texture has encoded float values, any linear interpolation before decoding harms the depth value. Without linear interpolation shadows/projections look like a grid when images are projected onto model

    What could be a solution?