Photoscenery: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(→‎Why use photoscenery?: remove duplicate text)
(→‎Using photoscenery: now mentioned in the #Texture overlays section)
Line 136: Line 136:
# Place the model as any other 3D object in the scenery.
# Place the model as any other 3D object in the scenery.
# Remove the corresponding <tt>Terrain/.../... .stg</tt> file to hide the normal scenery.
# Remove the corresponding <tt>Terrain/.../... .stg</tt> file to hide the normal scenery.
== Using photoscenery ==
<font color="red">'''Note:''' We're currently talking about possibly supporting orthographic overlays via [[Canvas]], so that patching would no longer be required, please see: [http://forum.flightgear.org/viewtopic.php?f=5&t=21882&p=201862#p201862]</font>
The overlay photoscenery method is not supported by default in FlightGear. Both [[SimGear]] and fgdata need to be patched. To do this one needs to [[Building FlightGear|build FlightGear from source]].
# Apply the <tt>simgear/io/sg_binobj.hxx</tt> patch from http://blaniel.free.fr/pub/flightgear/brest/photo_simgear.diff [http://codepad.org/UYP4NB8V] ('''note:''' this diff spans multiple files, but only the <tt>sg_binobj.hxx</tt> part should be used!).
# Apply the patches to SimGear and fgdata from http://fgphotoscenery.square7.ch/flightgear_photo_combined.patch [http://codepad.org/Oas9iydO]
# Compile SimGear and FlightGear.


== Extending the photoscenery support in FlightGear ==
== Extending the photoscenery support in FlightGear ==

Revision as of 10:37, 12 September 2019

A Cessna 172P flying over 1m/pixel photoscenery of Brest, France.

Photoscenery is scenery in which orthoimagery (aerial photograph) is placed over the terrain.

Why use photoscenery?

Advantages:

  • Photoscenery shows the real world, it does not try to resemble it.
  • Areas blend realistically, instead of a hard cut between urban and forest, or water and land for example.

Disadvantages:

  • One needs large (or many) textures for high resolution scenery. For low level (VFR) flying, 1m/pixel is the absolute minimum.
  • Orthoimagery is often hard to obtain, especially under an open license.

Obtaining orthoimagery

  • USGS, provides 3m/pixel imagery for the entire United States of America, released in the public domain (and thus GNU GPL compatible).

The prefered way of downloading these images depends on the used method Please read how to create photoscenery, before starting.

Preprocessing

  • Since FlightGear adds haze to the scene, the textures should be "unhazed" to avoid double hazing.
  • Shadows included in the images will conflict with shadows added by FlightGear. When creating small areas, shadows can be removed by hand from the textures, but this is usually undoable.

Creating photoscenery

There are several ways of creating photoscenery for FlightGear, of which some are discussed here.

Feature Texture overlays Texture materials 3D Model osgEarth Canvas Scenery Overlays Comment
Supported by stable FlightGear release No No Yes No Pending Pending
Toggle on run-time Yes No Yes Yes Pending Pending With the current patch, the textures overlays are always loaded.
Water reflections, random buildings/trees Yes No No No Pending Pending Depends on accuracy of underlying terrain (shapefiles)
Texture masks (not-so random objects) No Yes No No Pending Pending
Requires no adapted scenery Yes No No No Pending Pending
High resolution ca. 4m/pixel 1m/pixel or higher Yes Pending Pending
Advanced weather support Yes No No No Pending Pending Depends on accuracy of underlying terrain (shapefiles)
Requires no custom materials file Yes No Yes Yes Pending Pending

Texture overlays

This method places the photo texture on top of the normal scenery. It requires patches to be applied to the fgdata and SimGear sources.

  1. Calculate the tile bounds.
  2. Cut the orthoimagery to the bounds of the tile and save it with the tile's name (e.g. 3023737.png).
    A 4096*4096 pixel texture gives roughly a 4m/pixel resolution. Most graphics cards cannot handle larger textures, so when distributing the scenery this can be considered to be the limit. Tests on various machines showed that 16384x16384 pixel textures are possible (1m/pixel).
  3. Mirror the texture upside down.
  4. Convert the texture to .dds via NVidia's nvcompress (part of the NVidia Tools).
    It was found that 16384x16384 pixel textures can not be processed by nvcompress. The DDS plugin for GIMP worked fine though.
  5. Place this texture next to the respective .btg.gz file.

Simply launch FlightGear with $FG_SCENERY set to your scenery directory. Disable all shaders in the View > Rendering Options dialog. Model and Water can be enabled, but all other shaders will disable the photoscenery.

Note: Step 1 to 5 can be done by the photoscenery perl script from the FGScenery tools, when the imagery is obtained via a Web Map Service (WMS).

Texture materials

Another approach is to add each photo texture as a "material" in the materials.xml file.

  1. Calculate the tile bounds with the python scripts from http://fgphotoscenery.square7.ch/#howto.
    When creating low resolution scenery (4m/pixel or lower), a single 4096*4096 pixel texture can cover one tile. Higher resolution scenery requires the tile to be cut into smaller pieces: we'll call those photo tiles.
  2. Repeat the following steps for each single photo tile.
    1. Mirror the texture upside down.
    2. Convert the texture to .dds via NVidia's nvcompress (part of the NVidia Tools).
    3. Create a shapefile with the size/location of the texture. Save the shapefile with an unique name (e.g. 302373_3_2.shp, where the 3_2 indicates the horizontal/vertical tile id. This is not needed when using just one texture per tile).
  3. Generate the scenery with TerraGear, using the shapefiles as input.
  4. Currently TerraGear does not create good uvmaps, so some manual steps are needed:
  5. Import (one of) the btg.gz file(s) in Blender via the Blender and BTG plugin.
    1. Correct the uvmapping of each single sub-tile. The map should cover the texture exactly.
    2. Export the file again. Please note that you cannot re-import the file after exporting, so do not close Blender before verifying that the uvmapping is correct!
  6. Create a materials.xml file for your project. For example $FG_ROOT/Photoscenery/materials-nl.xml for Dutch scenery.
  7. Add a material definition for each single sub-tile, like:
    <material><name>3023745_1_1</name><texture>NL/3023745/3023745.1.1.dds</texture></material>
    The texture path is relative to $FG_ROOT/Textures.

Now launch FlightGear with $FG_SCENERY set to the output directory of TerraGear and the command --materials-file=Photoscenery/materials-nl.xml (for example).

3D Model

Prague, using the 3D model method.

Instead of using the normal terrain, one could replace it by a big 3D model.

  1. Create a 3D model of the terrain and texturize it with the orthoimagery.
  2. Place the model as any other 3D object in the scenery.
  3. Remove the corresponding Terrain/.../... .stg file to hide the normal scenery.

Extending the photoscenery support in FlightGear

For the earlier mentioned reasons, the texture overlay method seems to be the best and easiest for scenery developers. Nevertheless there are a few issues, stopping us from implementing it in the default FlightGear.

  • It unconditionally uses texture unit 3 in the terrain fragment shader, even if no photo-realistic texture has been found.
  • It seems to blend the photo textures with the default material textures using the alpha value of the photo texture, but that isn't documented anywhere. The purpose of this is unclear (why would you want to blend something photo realistic with a material texture in the first place).
  • It currently does not enable clamping, resulting in black tile borders.

Once there is basic support, a method should be found to split a single scenery tile into multiple texture tiles, so the resolution can be higher than 4m/pixel.

Projects

Several example photoscenery projects. The text between brackets indicates what method is used.

Also see