Photoscenery: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(Fix broken links, add note about required patches with texture overlay method)
Line 104: Line 104:


=== Texture overlays ===
=== Texture overlays ===
This method places the photo texture on top of the normal scenery.  
This method places the photo texture on top of the normal scenery. It requires [http://blaniel.free.fr/pub/flightgear/brest/ patches to be applied] to the fgdata and SimGear sources.


# Calculate the tile bounds with the python scripts from http://fgphotoscenery.square7.ch/#howto.
# Calculate the tile bounds.
# Cut the orthoimagery to the bounds of the tile and save it with the tile's name (e.g. <tt>3023737.png</tt>).  
# Cut the orthoimagery to the bounds of the tile and save it with the tile's name (e.g. <tt>3023737.png</tt>).  
#: 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).
#: 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).
Line 115: Line 115:
Simply launch FlightGear with [[$FG_SCENERY]] set to your scenery directory. Disable all shaders in the <tt>View > Rendering Options</tt> dialog. Model and Water can be enabled, but all other shaders will disable the photoscenery.
Simply launch FlightGear with [[$FG_SCENERY]] set to your scenery directory. Disable all shaders in the <tt>View > Rendering Options</tt> 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 {{gitorious source|fgscenery|tools|text=FGScenery tools}}, when the imagery is obtained via a [http://en.wikipedia.org/wiki/Web_Map_Service Web Map Service] (WMS).
'''Note:''' Step 1 to 5 can be done by the photoscenery perl script from the {{sourceforge source|flightgear|fgscenery/tools|path=Photoscenery|text=FGScenery tools}}, when the imagery is obtained via a [http://en.wikipedia.org/wiki/Web_Map_Service Web Map Service] (WMS).


=== Texture materials ===
=== Texture materials ===

Revision as of 10:31, 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.

Photoscenery / osgEarth has advantages and disadvantages (...) The difference between a tarmac surface and a swamp in photoscenery is the color of the pixel. In the 2.0 World Scenery, the difference is that both surfaces will interact with your airplane in quite different ways if you try to land. Tarmac will heat in the sun and be likely to spawn thermals and convective clouds, swamp will not. Tarmac will be less snow-covered when the snowline moves than swamp. The visual roughness of tarmac and swamp seen from 300 ft altitude will be very different. Swamp will appear wet and lead to more puddles in rain. The effect of both surfaces on the boundary layer winds is subtly different, as wind goes more easy over a rough surface. There’s more to Flightgear than meets the eye… and to some of us, these aspects factor as well.Photoscenery / osgEarth has advantages and disadvantages (...) The difference between a tarmac surface and a swamp in photoscenery is the color of the pixel. In the 2.0 World Scenery, the difference is that both surfaces will interact with your airplane in quite different ways if you try to land. Tarmac will heat in the sun and be likely to spawn thermals and convective clouds, swamp will not. Tarmac will be less snow-covered when the snowline moves than swamp. The visual roughness of tarmac and swamp seen from 300 ft altitude will be very different. Swamp will appear wet and lead to more puddles in rain. The effect of both surfaces on the boundary layer winds is subtly different, as wind goes more easy over a rough surface. There’s more to Flightgear than meets the eye… and to some of us, these aspects factor as well.

Also for photo texturing, do some back of the envelope estimates of number of bytes per second we'd need to page in/out at various airspeeds at various resolutions ... keeping in mind 1 pixel per meter isn't very detailed resolution if you are thinking about road edges, runways, runway markings, etc. It could look awesome from 3000' AGL though. There are pluses and minuses to every approach ... that doesn't necessarily make one way better or worse or easier or harder ... just that every approach has it's limitations and downsides and challenges for implementation ...

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.

Using photoscenery

Note: We're currently talking about possibly supporting orthographic overlays via Canvas, so that patching would no longer be required, please see: [1]

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 build FlightGear from source.

  1. Apply the simgear/io/sg_binobj.hxx patch from http://blaniel.free.fr/pub/flightgear/brest/photo_simgear.diff [2] (note: this diff spans multiple files, but only the sg_binobj.hxx part should be used!).
  2. Apply the patches to SimGear and fgdata from http://fgphotoscenery.square7.ch/flightgear_photo_combined.patch [3]
  3. Compile SimGear and FlightGear.

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