Converting textures to RGB for use in FlightGear?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
JStevenson
Posts: 3
Joined: 2013-07-18T10:09:36-07:00
Authentication code: 6789

Converting textures to RGB for use in FlightGear?

Post by JStevenson »

Hello, this is my very first post to this forum so please be gentle if this all sounds terribly basic!

I'm attempting to import 3ds model meshes into the FlightGear flight simulation environment (version 0.9.10 to be exact). The 3ds meshes are coming across OK but the textures are not. The "stock" textures included with the 3ds are JPGs. However, FlightGear appears to want to use RGB format which from my basic reading is very low-level. The error message I get from FlightGear suggested to me to install ImageMagick and use it to convert the JPGs to RGB. Which I dutifully did ;-)!

I used the CONVERT command to create an RGB version of one of the JPGs as a test. However, when I now re-launch FG it eventually triggers a FATAL ERROR when it attempts to use this new RGB file. The exact error message is: Unrecognized magic number 0x6ec5.

If anyone here already has experience doing this (i.e. creating FG-compliant RGB) I would appreciate any advice or help.

Cheers and thanks in advance,
Jon
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting textures to RGB for use in FlightGear?

Post by fmw42 »

Does FG give any specifications for what it means by RGB. Is that raw pixel format or does it mean it wants a non-compressed 24-bit RGB format such as png or tiff?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting textures to RGB for use in FlightGear?

Post by fmw42 »

according to http://wiki.flightgear.org/File_Formats

rgb format is SGI Image Format

"FlightGear uses plib to read SGI images. They must not use 16 bits per plane and must have side lengths of 2nx2m (powers of 2), the size must be at least 4 pixels when using compressed textures (automatic feature in the osg branch). For example: 64x64, 256x256 or 128x2048 (but textures have square size inside the graphic card so a 16x1024 texture is really a 1024x1024 texture). Note that other sizes will not work, and FlightGear will use a red/white chequered texture instead! FlightGear textures shall be RLE-compressed, and as 'aggressively' as possible."

So in IM

convert your .jpg images to the correct size and output to .sgi

see http://www.imagemagick.org/script/formats.php
JStevenson
Posts: 3
Joined: 2013-07-18T10:09:36-07:00
Authentication code: 6789

Re: Converting textures to RGB for use in FlightGear?

Post by JStevenson »

Thanks for the very thorough reply. I will try this technique right now.
Once in *.sgi format I assume I'd rename to *.rgb? I notice that all of the (working) textures in FG are *.rgb.
I'll reply again once I've tried all this.
Cheers,
Jon
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting textures to RGB for use in FlightGear?

Post by fmw42 »

I presume you do not need to rename the suffix from that article.

But you can try both ways.

According to IM http://www.imagemagick.org/script/formats.php

SGI RW Irix RGB image

so .sgi is and SGI Irix RGB image
JStevenson
Posts: 3
Joined: 2013-07-18T10:09:36-07:00
Authentication code: 6789

Re: Converting textures to RGB for use in FlightGear?

Post by JStevenson »

The conversion from JPG and PNG to SGI worked well. I used PAINT to resize a few JPGs which were of irregular size (i.e. to make sure they were some power of 2 dimensions, eg. 128x32, 128x128, 256x256).

Identify said the new SGIs were RGB but I renamed them with *.rgb extension anyways and FG was happy with this. My textures are now displaying OK.

Only Caveat was the single PNG source was a semi-transparent "metal railing" which came out as a black and white opaque texture but otherwise looks fine.

So I think this thread is resolved.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting textures to RGB for use in FlightGear?

Post by fmw42 »

SGI format does support transparency. See ftp://ftp.sgi.com/graphics/grafica/sgiimage.html

This works fine for me


convert logo: -transparent white logo.sgi
convert logo.sgi logo.png
display logo.png


Try importing using .sgi suffix and see if that keeps the transparency. Otherwise, I suspect it is a FG limitation.
Post Reply