Search Unity

RAW Encoder for Unity Terrain Map?

Discussion in 'Editor & General Support' started by sullivansean27, Apr 11, 2017.

  1. sullivansean27

    sullivansean27

    Joined:
    Aug 18, 2014
    Posts:
    2
    Hi,

    I'm writing an external C/C++ program which currently exports 16-bit greyscale PNG files based on data that I have within the program using lodepng. I'd like to be able to visualize these in Unity as terrain maps without jumping through a series of hoops (or repeatedly going into Photoshop/GIMP) to get my 16-bit greyscale data into the RAW image file format required for Unity terrain maps. Independent research has told me that the RAW image format is more of a shorthand for a variety of camera outputs, but if so why is Unity using them? Is there a specification for whatever variety Unity is using, so that I can look to manually encode them? Or maybe a library? This may include headers / endianness of the required format, etc....

    Any details are useful at this point, whether there is a simpler path or if this is simply impossible. (I'd prefer not to port my code to C# right now, but maybe there is a simpler vertex-map type thing I could use?)

    Thanks for your time.

    Best,
    Sean
     
  2. grizzly

    grizzly

    Joined:
    Dec 5, 2012
    Posts:
    357
    Those RAW files just store 16-bit (UInt16, 2 byte stride) pre-formatted height data. They are not encoded and have no header. You should be able to just write directly into them in (I think, best check) big-endian order.
     
  3. sullivansean27

    sullivansean27

    Joined:
    Aug 18, 2014
    Posts:
    2
    Thanks!