Request for TIF support

Progress: LibTiff on Linux tested and rocks, TGrayscaleFloatImage also on GPU.

Details:

  • I changed loading from Vampyre to fail with proper exception in case some format cannot be loaded, e.g. because libtiff is not available. This is a better behavior, consistent also with rest of CGE, better than previous accidental behavior of silently loading an image with zero size.

    We want to avoid experience like @edj mentioned a few posts up – “But the tifs are still either stairstepping, or displaying corrupt looking results or nothing at all.”. If we failed to read the image, there shall be a clear exception.

  • Tested and documented how to get libtiff.so.5 on Linux . Works great on Linux, and yes, I get float-based images from samples in this thread! Please see castle-engine/doc/miscellaneous_notes/additional_image_formats.md at master · castle-engine/castle-engine · GitHub .

  • Caveat: If image contains alpha channel, it is still converted to 8-bit, for today. The reason for this is trivial, we just don’t have TRGBAlphaFloatImage (we only have TRGBFloatImage and TGrayscaleFloatImage). I should add TRGBAlphaFloatImage soon.

    For today, just make sure your image doesn’t have alpha, if you want it to see read to high precision (floats) instead of 8-bit Bytes.

  • I added branch extra-image-formats to GitHub - castle-engine/castle-image-viewer: Image viewer and converter using Castle Game Engine, supporting many common image formats (PNG, JPG...) and some exotic ones (DDS, KTX, RGBE) to demonstrate this, i.e. precompiled libtiff.

  • Note that I thought about making TIFF more out-of-the-box supported in CGE, but resigned for now – this extra need to get libtiff is another hurdle, so reason to not recommend people to use TIFF and instead recommend PNG for now (where we have LibPNG distributed everywhere already). But, if you need TIFF, the ability is there and at least better documented now.

  • We support now loading TGrayscaleFloatImage to GPU (OpenGL), so such texture formats are even more useful – e.g. we can pass float-based heightmaps to shaders.

    (This is not something necessary for usage in TCastleTerrainImage, but it’s nice anyway.)

    You can see proof of it above. Castle Image Viewer displays it as float image, so it’s really not converted to 8-bit at any point in CGE. We can also resize such images (in case they don’t fit in OpenGL max texture size).

1 Like