How could I read .raw file in Unity?

1.3k Views Asked by At

I have downloaded some .raw file of depth data from this website.

3D Video Download

In order to get a depth data image, I wrote a script in Unity as below: enter image description here

However, this is the texture I got. enter image description here

How can I got the depth data texture as below? enter image description here

1

There are 1 best solutions below

0
On

RAW is not a standarized format, while most of the variants are pretty easy to read (there's rarely any compression) its might not be just one call to LoadRawTextureData.

I am assuming you have tried other texture formats than PVRTC_RGBA4 and they all failed?

First off, if you have the resolution of your image, and file size, you can try to guess the format, for depth its common to use 8bit or 16bit values, if you need 16 bit you take two bytes and do

a<<8||b  

or

a*256+b

But sometimes there's another operation required (i.e for 18bit formats). Once you have your values, getting the texture is as easy as calling SetPixel enough times