I've been using the terrain scene node, but getting some slightly unexpected results. I'm loading the heightmap from a greyscale (8 bit) bmp file, and would expect to get elevations from 0 to 255 units (pure black to pure white). However, the maximum height was coming out at 239.
I've been checking the createImageFromFile method with different types of bitmap, and seem to get inconsistent results. If I load a regular RGB (8 bit) bmp file, the pixel colours are as expected. However, if I load a greyscale bitmap, and check the colours with getRed etc, I get odd results with pure white giving (239,239,239) and pure black giving (82,66,66) r,g,b values. All bitmap images were created with Gimp (2.8.10)
As I'm just starting to use the engine, I'm not sure if I'm making some mistake, but would like to know if this behaviour is expected? This is with Irrlicht 1.8.1 (Build 9200) using renderer: OpenGL 4.0.0.
I have uploaded a simple test case at http://www.bridgecommand.co.uk/data/_up ... leTest.txt, which demonstrates this with 4 images: testBlackGreyscale.bmp testBlackRGB.bmp testWhiteGreyscale.bmp and testWhiteRGB.bmp.
Odd behaviour when loading a greyscale BMP
Odd behaviour when loading a greyscale BMP
-------------------------------------
Bridge Command
a 3d ship simulator for navigation training
Bridge Command
a 3d ship simulator for navigation training
Re: Odd behaviour when loading a greyscale BMP
Doesn't the terrain use the hue for height? Not sure how that converts
Re: Odd behaviour when loading a greyscale BMP
I think the terrain loader uses getLightness(), which returns the average of max(r,g,b) and min(r,g,b). Therefore if the r, g and b values are identical, as you would expect in a greyscale image, it will return this value.
After a bit more digging, it seems as if the problem is related to the format of the BMP image used. There are different versions of the BMP header, and it seems that the one used by default by Gimp 2.8 for greyscale BMPs is not properly read by Irrlicht (and various other programs, see for example https://www.allegro.cc/forums/thread/61 ... 939#target). For the moment I can work around this by using Gimp's 'do not write color space information' export option.
After a bit more digging, it seems as if the problem is related to the format of the BMP image used. There are different versions of the BMP header, and it seems that the one used by default by Gimp 2.8 for greyscale BMPs is not properly read by Irrlicht (and various other programs, see for example https://www.allegro.cc/forums/thread/61 ... 939#target). For the moment I can work around this by using Gimp's 'do not write color space information' export option.
-------------------------------------
Bridge Command
a 3d ship simulator for navigation training
Bridge Command
a 3d ship simulator for navigation training
Re: Odd behaviour when loading a greyscale BMP
FYI, greyscale PNGs load fine, and are maybe a hundred times smaller than the comparable BMP.