I am working with a depth sensor (Orbbec Astra Pro) and want to display the infrared image in Unity. The data I receive is an ushort[] (or any other type, which is larger than 8bit).
So I can create a single channel 16-bit texture infraredTexture = new Texture2D(infraredFrame.Width, infraredFrame.Height, TextureFormat.R16, false);, but I do not know how to fill the texture with the infrared data, as LoadRawTextureData only takes a byte[] or IntPtr.
So in the end I would like to see a 16-bit grayscale texture in Unity. Is this even possible? Thank you in advance!
In general note from
TextureFormat.R16I don't have a direct solution for if you actually want to use a
R16format texture except somehow serialize the data tobyte[]e.g. usingBuffer.BlockCopy- NOTE: No idea of this would work at all!Again no clue if it works that way.
However, I think you could simply "fake" it in Unity. If it is only for displaying the texture anyway you could rather use a "normal"
RGB24texture and simply map your 16-bit single channel data into a grey scale 24-bit RGB color and then apply it usingTexture2D.SetPixelslike e.g.