Howto:Methods to replace the dial gauge bit mapped texture with vectorial objects

From FlightGear wiki
Jump to navigation Jump to search

In the FIAT G91-R1B project it was necessary to realize high resolution analog gauges (tolerance <1/10 mm) to allow a better visualization of the instruments and therefore a more comfortable simulated flight experience. The creation of high resolution analog gauges required the creation of the instruments with a CAD program called Freecad (very suitable for mechanical and micromechanical parts). FreeCAD is an open source project based on OpenSCAD libraries initially developed for the US Army. Unfortunately Freecad does not contain a .ac converter, but you must first go to Blender via the .obj format and then convert to .ac format. If you want to obtain a resolution of the dial lower than 1/10 of mm it is necessary to use 1024 textures because the gauge has an average dimension between 50-100 mm. Flightgear's airplanes rarely have gauge dials so detailed and so this work has served to show that the Flightgear system is still capable of working effectively with dozens of high-resolution gauges. But sometimes, especially for smaller PCs, it may happen to witness an evident slowdown and in some cases the abort of the program for an evident end of the available resources. To overcome this drawback, a detailed analysis of the causes was made and it was found that the problem was due to the high amount of 1024 textures present in the cockpit instruments. The reason is substantially related to the internal mode of operation of modern GPUs that convert a bitmapped image into vertices that with tens of images with a size of 1024 can lead to the saturation of memory available. Therefore, the solution can be given by using a different paradigm in which the bitmapped image is substituted with an equivalent vectorized image.

Efficiency in converting a bitmapped image into vector

A dial image is essentially an image consisting of 90-95% of empty pixels. Therefore, in this case, it is possible to apply the method of converting bitmapped image in vector. This method is not always advantageous, if the bitmapped image is complex, such as a geographic map, the conversion into vector format, described in this how-to, may not have the desired benefits. Even the characteristics of the bitmapped image can greatly change the quality of the conversion work and therefore it is necessary to make some tests to understand if this is a useful way to solve the problem.

Converting a raster image to vector

In the open-source spirit of Flightgear everything that is explained here must be freely available and without particular constraints on the propiety of the work done. I want to remind you that many converters on the Internet change the terms of intellectual property of the processed content and are therefore not compatible with Flightgear.

For the enhancement of bitmaps in this how-to is proposed Inkscape that is very used by the developers of Flghtgear and often many textures were made with Inkscape (SVG format) and then converted to PNG or via canvas used directly on the surfaces.

FIAT G91R1B Hydraulic pressure gauge with bitmap dial

So the main work is to take a PNG or 2D raster image with SVG format and convert it into a vectorized two-dimensional image. Sometimes it may be convenient to transform the vectorized two-dimensional image into a 3D image and this step will be explained as a technique to simulate the characters carved by punching on the knobs.

On the right you can see the appearance of a medium-sized gauge (about 2 inches). As you can see the gauge is made with four bitmapped layers that define the colors and the levels on the surfaces (bottom for the bicolour graduated circle, medium for the description, hight for the arc applied on the glass). Each of these layers also has a different reflectance and light emission properties.