Howto:Adding Cliffs To Terrain: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
No edit summary
(+ Link to forum topic)
Line 63: Line 63:


The cliff effect includes both procedural texturing at highest rendering quality settings, and normal ALS texturing otherwise. Parameters for procedural texturing are the same as those for rock: see the relevant section of the [[Procedural Texturing]] page. Proper texturing relies on cliffs that were generated with the <code>--texture-cliffs</code> option (see above).
The cliff effect includes both procedural texturing at highest rendering quality settings, and normal ALS texturing otherwise. Parameters for procedural texturing are the same as those for rock: see the relevant section of the [[Procedural Texturing]] page. Proper texturing relies on cliffs that were generated with the <code>--texture-cliffs</code> option (see above).
==Related content==
===Forum topics===
* [https://forum.flightgear.org/viewtopic.php?f=5&t=35173 Adding cliffs to terragear] (December 2018-)


[[Category:Howto]]
[[Category:Howto]]
[[Category:Scenery enhancement]]
[[Category:Scenery enhancement]]

Revision as of 16:36, 19 April 2019

WIP.png Work in progress
This article or section will be worked on in the upcoming hours or days.
See history for the latest developments.

Why do cliffs require special treatment?

Terrain generated from elevation data on a grid (e.g. Shuttle mission SRTM data) will tend to smooth out abrupt changes in height, such as cliffs. This is because each point on the grid records the average height in the region of the point, and TerraGear will, by default, smoothly interpolate between these points. So even if the grid elevation points were true point heights, the change in elevation is spread over the distance to the next grid point and cliffs become steep (or not-so-steep) slopes. The procedure below describes how to avoid these smoothing effects and properly texture the resulting near-vertical surfaces.

The following instructions assume that you are familiar with the TerraGear toolchain, extracting data from OpenStreetMaps, and creating shapefiles. In the commands below, <scenery_top> refers to a directory with a conventional layout for scenery construction, that is, containing shapefile and height data in data, intermediate files in work, and output in output. Other files are placed in scenery_top/rawdata

Preparation

The procedure below assumes that you have already prepared elevation data as described in Using TerraGear.

Step 1: extract cliff data

OpenStreetMaps records the location of cliffs by attaching the tag "natural=cliff" to line features. Extract these features into a shapefile. The example below uses osmosis to extract data from an OSM pbf file covering Australia into OSM XML file cliffs.osm, which is then converted to shapefile cs_cliffs using ogr2ogr:

osmosis --read-pbf <scenery_top>/rawdata/australia-latest.osm.pbf --bounding-box top=-31 bottom=-36 left=114 right=119 completeWays=yes --lp --tf accept-ways '
natural=cliff' --tf reject-relations --used-node --write-xml file='<scenery_top>/rawdata/cliffs.osm'
ogr2ogr -where "OGR_GEOMETRY='LineString'" -f 'ESRI shapefile' -lco SHPT=ARC <scenery_top>/data/cs_cliffs <scenery_top>/rawdata/cliffs.osm

Fixing the topography

Step 2: add cliff data to height data

Tool cliff-decode distributed with TerraGear (version "next" as of early 2019) takes a cliff shapefile for an area and divides it up amongst the height tiles ("buckets") that make up that area, so that elevation calculations can use these cliff lines as known discontinuities in the topography. The first argument is the location of the directory tree containing height files, and the second is the shapefile generated in the previous step:

cliff-decode <scenery_top>/work/SRTM-3 <scenery_top>/data/cs_cliffs

The example command places multiple files with extension cliffs in each of the area tile subdirectories underneath the SRTM-3 directory, if any cliffs are present, of course! TerraGear (version 2019.1 "next") will not interpolate elevations across any of these cliff lines when constructing terrain.

Step 3: rectify heights (optional but desirable)

The rectify_height tool supplied with Terragear (version "next" as of early 2019) uses any cliffs files found in the elevation directories to improve the elevation information. The argument --min-dist specifies how far away from a cliff a point must be in order for its height to be trustworthy. Any points closer than this distance will be interpolated from the trustworthy points. If no trustworthy points can be found (for example, the top of a small butte), the elevations are not changed. A suitable value should be at least 1 elevation grid spacing.

rectify_height --work-dir=<scenery_top>/work/ --height-dir=SRTM-3 --min-lon=151.0 --max-lon=152.0 --min-lat=-34.0 --max-lat=-33.0 --min-dist=100

After running this command a series of files with extension rectified will be found in any elevation subdirectories within the lat/long boundaries. TerraGear will preferentially use these files when interpolating elevations, as well as not interpolating across cliff lines. If you skip the rectification step, TerraGear with rectify on the fly for every point, potentially duplicating rectification calculations for the same group of points many times.

Adding cliff objects to the terrain

The previous steps have only corrected the elevation calculations for points in the vicinity of cliffs. Unless a terrain object is created that runs along the cliff line, the cliff itself will not appear.

Step 4:Adding cliff quadrilaterals to the terrain

Cliffs are created from the line data created in Step 1, using the same ogr-decode used for other shapefiles. Use an area type of "Cliffs" to match the type used in default-priorities.txt. The line width of 5 metres means that the horizontal distance from the bottom to the top of the cliff will be 5 metres. This can be made smaller or larger as desired. The additional --texture-cliffs option will ensure that the texture coordinates map onto the cliff face and that neighbouring faces match; without this option the texture coordinates will be calculated from the latitude and longitude, leading to textures that are very stretched vertically.

ogr-decode --line-width 5 --texture-cliffs --area-type Cliffs "<scenery_top>/work/Cliffs" "<scenery_top>/data/cs_cliffs"

Building the new scenery

Run tgconstruct as usual, making sure to include the Cliffs directory created in step 4.

Texturing cliffs

Refer to the Howto:Regional Texturing page for general information on setting up regional materials. A cliff Effect is supplied with Flightgear (in "next" from early 2019). To use this, simply add the following at the top of the material definition file for the region:

 <material>
 <name>Cliffs</name>
  <effect>Effects/cliffs</effect>
  ... (elided)
 </material>

The cliff effect includes both procedural texturing at highest rendering quality settings, and normal ALS texturing otherwise. Parameters for procedural texturing are the same as those for rock: see the relevant section of the Procedural Texturing page. Proper texturing relies on cliffs that were generated with the --texture-cliffs option (see above).

Related content

Forum topics