[leveller] Re: 16 and 24 bit output format question.

  • From: Ray Gardener <rayg@xxxxxxxxxxxxxxxxxx>
  • To: leveller@xxxxxxxxxxxxx
  • Date: Fri, 02 Sep 2005 00:25:12 -0700

I was wrong about a possible byteswap error on 16-bit elev exports to BMP/TGA... turns out the byteorder was correct. There might be a problem with TGA normal images at 16-bit, but it just so happens that Leveller never outputs such pictures (it uses 24 bit for picture exports).

However, the TGA 16-bit elev export didn't take the pixel's attribute bit into account, so it was a little off. I've adjusted it to do a 15-bit export and leave the attribute bit to zero and now it's coming up matched equal to the BMP export. The error wouldn't mangle anything -- it would just cause a loss of one bit of precision -- so if you're getting weirder results, then it remains a mystery. If you have some elevdata BMP/TGA/PNGs you can send in along with the source TER, I can examine them.

Ray



Ray Gardener wrote:
What formats (exactly)are the 16 and 24 bit output bitmaps using?


It depends on the file format. 16-bit PNG will use 16-bit grayscale.
16-bit TGA/BMP will use a 15-bit 5-5-5 RGB encoding, and
24-bit will use a red * 65536 + green * 256 + blue encoding.

24-bit pixels are written in BGR order.

16-bit BMP/TGA may be wrong; they are writing without
the pixels byteswapped. I'll have to look into this and verify.

Thanks,
Ray




By that I mean how is a pixel’s height calculated?



I’m outputting to Maya which apparently only understands gray scale – odd things happen when using 16 of 24 bit. However, using the power of Maya’s Node concept, I can easily calculate my own pixel heights.



I need more than 8 bit as this is Valles Marinaris, which has a lot of steep hillsides and flat rolling dunes in it – with 8 bit resolution there are artifacts.


I’ve done some samples and the ‘native’ Maya appears to sum up all 3 RGB values to calculate the height. I imported a bitmap with a red, green, and blue ramp and it looks like Leveller uses the R as a MSB, which would give more dynamic range (i.e. the height is a 24 bit value using RGB as the 3 byte values).



If this were the case I should use R*65536+G*256+B but that seems to give weird results.



So how should I build my Maya nodes to properly calculate a 24 bit, bitmap export height based on the R,G, and B values?



                        == John ==





Other related posts: