• Advertisement
Sign in to follow this  

Save HeightMap to file

This topic is 2631 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all!

I need to save a procedurally generated heightmap (stored as float[]) to grayscale texture. I'm currently using the Texture2D.SetData<> method, Color format for texture and clamping array values to float.MinValue, float.MaxValue... but this give me weird results.

Thanks a lot!

Share this post


Link to post
Share on other sites
Advertisement
I answer myself:

It's simply.

Since pixels from texture gets values between 0 and 255 for rgba channels, transposing the height values to [0, 255] is enought to construct the gray Color (r = g = b ) wanted to set texture data.

Cheers

Share this post


Link to post
Share on other sites
255 levels of height won't cut it in all circumstances. You might want more, and that means using 16 bit instead of 8 for representing them. That really should be enough for anything you can imagine game related. The way you encode it in the file it depends. Personally, I would just have a file with 16 bpp, but if you want to stick with your channels you can store the major byte in red channel and the minor one in the green channel, or really any other combinations would work.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement