Board index FlightGear Development Scenery

Adding cliffs to terragear

Questions and discussion about enhancing and populating the FlightGear world.

Adding cliffs to terragear

Postby frtps » Wed Dec 26, 2018 1:11 am

I have been playing with terragear to see if I can get cliffs to appear in the terrain around Sydney (Australia). There are a lot of cliffs around here, both along the sea coast and inland in the "mountains" (and thus a thriving rock-climbing community) but these cliffs don't appear in FlightGear terrain, and as far as I can tell this is because:
(1) SRTM-3 height data is an average value and thus averages out top and bottom cliff heights
(2) terragear interpolates heights between values on the SRTM-3 grid, so even with e.g. ViewfinderPanorama heights, there is a smoothing effect.

The current result of my experimentation is below:

Image
1. Looking south along the coast south of Sydney, default FlightGear scenery

Image
2. Same location as above, after cliffs added

Image
3. Sydney north head (north entrance to the harbour) after adding cliffs. The current scenery for Sydney north head is wrong in too many ways to bother including for comparison (there is no massive heliport there [now removed from WED], there is no urban landcover either, the coastline is way off)

Note that images 2 and 3 use Statto's improved landcover classes, but I've not included all classes in order to save processing time. I have also used OSM coastlines (see below for why this is necessary).

These cliffs are produced as follows:
(1) Cliffs are extracted from OpenStreetMaps data using the condition "natural=cliff"
(2) ogr-decode is used on these files to create lines of cliffs in the terragear working directory in the same way as roads and rivers (line data) are currently processed by ogr-decode. That is, the cliff line is replaced by a sequence of narrow quadrilaterals, material type = Rock.
(3) A new tool "cliff-decode" which is a stripped-down version of ogr-decode is run on the same OSM data to place cliff line data in the directories containing the height data
(4) A new tool "rectify_height" is run over the height arrays. This tool assumes that all heights within a certain distance (say 100m) of a cliff will not be an accurate point height. These heights are discarded and replaced by heights interpolated from the remaining heights, performing multiple passes if necessary. The cliff lines are considered discontinuities and never interpolated across.
(5) tg-construct is run as usual, using the rectified heights if available. My modified version does not interpolate heights across the cliff lines stored in the height directories. Cliffs appear because one side of the cliff quadrilateral generated at step (2) will be just inside the top, and the other side just past the bottom and thus these points are calculated to have radically different heights. Note that almost all of the changes are in Array.cxx, which is used by rectify_height and tg-construct.

Issues and improvements that remain:
(1) Where sea cliffs don't match the coastline exactly, they will become very jagged as any point considered to be part of the sea will be set to a height of zero. So the coastline data should be as good as the cliff data.
(2) I've tried using procedural rock texturing for the cliffs (which would be cool) but they seem to become reflective. Is it possible that the shaders are not designed for viewing rock from the side?
(3) cliff-decode uses the clipper included in terragear to clip the cliff lines. However, these lines could be included in-toto as they are simply used to indicate discontinuity and there is no problem if they extend outside a bucket
(4) an order-of-magnitude speedup is available for cliff-rich areas like Sydney if bounding boxes of the cliff lines are stored to save checking against all cliffs in a bucket for every pair of points when interpolating.

I think it would be great if this code could be merged into terragear. Perhaps a "cliff" topic branch could be created if the above approach seems reasonable? Or should I submit a series of patches?
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Adding cliffs to terragear

Postby Thorsten » Wed Dec 26, 2018 9:06 am

I'd argue that there's something to be said for interpolation. Cliffs are steep, but not vertical, I've taken a look at some real life pictures of Sydney and surroundings, and even the steepest I could find are not as vertical as your version. It simply looks unnatural.


(2) I've tried using procedural rock texturing for the cliffs (which would be cool) but they seem to become reflective. Is it possible that the shaders are not designed for viewing rock from the side?


Likely the problem is the uv-mapping - terrain is by default uv-mapped with a vertical projection, so if your cliffs are exactly vertical, there's practically no texture coordinate space at all to work with. You'd have to switch to a different mapping if you want to apply any sort of texture (procedural or not).

(Of course a shader could conceivably use mesh geometry coordinates rather than uv-mapped coordinates based on a flag... might be worth a try)
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Adding cliffs to terragear

Postby frtps » Wed Dec 26, 2018 10:16 am

I'd argue that there's something to be said for interpolation. Cliffs are steep, but not vertical, I've taken a look at some real life pictures of Sydney and surroundings, and even the steepest I could find are not as vertical as your version. It simply looks unnatural.


Well, the slope can be set by changing the width of the strip created by ogr-decode. I have used 5m, that is, the base is displaced horizontally by 5m from the top. Here are some of the cliffs in the sample images in real life:

ImageNorth Head by Brian Bornstein, on Flickr

ImageSea Cliff bridge by sth475, on Flickr
(This corresponds to the coastal foreground of the first two screenshots that I posted).

To my eye the real-life cliffs look significantly more vertical than the result of interpolation. This is also the conclusion I draw from comparing the actual white cliffs of Dover with the FlightGear versions.

I suspect the lack of realism at present is more to do with the smooth texture. I have been more occupied with getting rid of topological artefacts than with texturing. I think with some appropriate texturing to simulate bumpiness, layering, transition at the top edge and so forth it would blend much better with the surroundings.

One thing I forgot to mention - if knowledge of cliffs is included in terragear, then we have river + cliff = waterfall, with some opportunities for nice rendering and e.g. increasing fog from spray at low altitude. I haven't flown over eg Niagara falls in FlightGear, so I wonder how it looks at the moment.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Adding cliffs to terragear

Postby Thorsten » Wed Dec 26, 2018 10:34 am

To my eye the real-life cliffs look significantly more vertical than the result of interpolation


When I say something is to be said for interpolation, I don't necessarily mean it has to be interpolation as done before - clearly there's too much smoothing. But interpolation is not a unique process - there's an infinity of ways to connect two points - so clearly it would seem possible to find a good interpolation.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Adding cliffs to terragear

Postby bugman » Wed Dec 26, 2018 11:08 pm

Please have a look at the FlightGear policy statement. There you will find that the place to discuss your developments is the FlightGear developer mailing list.

Regards,
Edward
bugman
Moderator
 
Posts: 1808
Joined: Thu Mar 19, 2015 10:01 am
Version: next

Re: Adding cliffs to terragear

Postby Alant » Thu Dec 27, 2018 1:33 am

The OP is to be congratulated on getting to grips with our sadly neglected Terragear and succeeding in adding an extra feature. Thanks and don´t be put off.

Alan
Alant
 
Posts: 1219
Joined: Wed Jun 23, 2010 6:58 am
Location: Portugal
Callsign: Tarnish99
Version: latest Git
OS: Windows 10/11

Re: Adding cliffs to terragear

Postby wlbragg » Thu Dec 27, 2018 6:26 am

frtps wrote in Wed Dec 26, 2018 10:16 am:
Well, the slope can be set by changing the width of the strip created by ogr-decode. I have used 5m, that is, the base is displaced horizontally by 5m from the top.

Have you tried a larger width to see if that helps with the texturing. Look like you coul add a significant distance and still have a vertical looking cliff. Absolutely, thank you for your efforts and by all means submit a patch including documentation if possible. And please do contact mailing list to discuss possibilities to expand on this.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Adding cliffs to terragear

Postby frtps » Thu Dec 27, 2018 10:56 pm

Thanks for the encouragement, I will switch my attentions to the mailing list for further discussion. But first I want to see if a little procedural texturing idea provoked by Thorsten has potential.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Adding cliffs to terragear

Postby Thorsten » Fri Dec 28, 2018 8:43 am

I believe a more correct solution would be to uv-map the cliffs inside terragear such that the upper and lower edge are 0 and 1 in vertical texture coordinates - in that way, cliffs could be nicely textured with transitions to level terrain.

But first I want to see if a little procedural texturing idea provoked by Thorsten has potential.


Unless you can do the GLSL coding required (it's not difficult as such, you just have to know what is what in a shader) this is going to be a longer wait till you see anything - I've started to work on coding some orbital rendezvous targeting math, so it will be a while till I have time to do other stuff.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Adding cliffs to terragear

Postby frtps » Sat Dec 29, 2018 12:00 am

OK, so while I am far from being a GLSL programmer I have created a procedural cliff texture by editing rock-ALS.frag to use length(rawPos.xy) and msl_altitude as the two coordinates for 2D noise, instead of rawPos.xy. The cliff texture in the pictures below is then generated using the example parameters for highly cracked rock together with colours sampled from a (public domain) photograph of a local cliff. From a distance I think the cliffs look pretty reasonable, close up there is still a bit of a reality gap. These are roughly the same locations used in the original post. Compare especially the cliffs in the middle distance of the top picture below with the first picture in the original post - while the topography in the default flightgear scenery looks realistic, the actual topography is closer to the first picture below (but I don't have a photo to prove it).

Image

Image

I believe a more correct solution would be to uv-map the cliffs inside terragear such that the upper and lower edge are 0 and 1 in vertical texture coordinates - in that way, cliffs could be nicely textured with transitions to level terrain.


I'm less confident as to how to map a texture, especially keeping track of when a vertex is at the top of the cliff, so I might first busy myself trying to get the basic code into terragear.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Adding cliffs to terragear

Postby Thorsten » Sat Dec 29, 2018 8:40 am

OK, so while I am far from being a GLSL programmer I have created a procedural cliff texture by editing rock-ALS.frag to use length(rawPos.xy) and msl_altitude as the two coordinates for 2D noise, instead of rawPos.xy.


Good - you do know what is what in a shader then :D

Knowing that your cliffs are steep, you can do a cross product between normal and up direction, that'll always give you the second texture coordinate near orthogonal to the msl alt.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Adding cliffs to terragear

Postby statto » Sat Jan 05, 2019 10:00 pm

Nothing much to add except that looks great.
Custom Scenery available from http://www.stattosoftware.com/flightgear
statto
 
Posts: 2106
Joined: Fri Jan 25, 2008 10:57 pm

Re: Adding cliffs to terragear

Postby frtps » Sun Jan 06, 2019 1:36 am

statto wrote in Sat Jan 05, 2019 10:00 pm:Nothing much to add except that looks great.


Thanks. If anybody would like to play with the code, it can be cloned from
Code: Select all
git://git.code.sf.net/u/jreh/flightgear
branch 'next'. I have sent a merge request so hopefully this will eventually be included in flightgear.

(My sourceforge-fu is obviously bad, the cloned repository should be called terragear as it is terragear only. And the branch should be called something topical, such as `cliffs`. Next time...)

The code is compiled exactly the same way as the main repository terragear (cmake in a build directory and then make).

I have added something at the end of 'README.Howto' describing how to add in cliffs. I would be interested in any successes or especially failures anybody has. A key thing to remember is that cliffs from OSM are more accurate than your typical landclass boundary, and so this may produce unrealistic artefacts, especially in areas where the cliffs border water. For example, a landclass polygon line segment originally forming the border with a water body might cut slightly inland from the OSM cliff line, leaving a gap to be filled between cliff line and the landclass, This gap by default becomes 'Ocean' with a height of zero. Or the polygon line segment extends out further than the cliff, producing a small area of e.g. urbanisation at the foot of a cliff and in some cases texturing the landclass down the cliff face - not sure why that happens at the moment, I think I need to learn those steps of terragear that happen after the elevations are calculated. These are the problems I am fiddling with in Sydney Harbour.

One idea would be to use cliff lines to 'rectify' landclass borders if they are within e.g. 30m of a cliff line. This could be done by a separate tool, or in-situ in terragear when all landclasses for a particular location are loaded. Or alternatively, the 5m wide cliff segment placed by ogr-decode could be embellished on either side with neighbouring quadrllaterals of type Rock. Or you could improve your landclass borders, or fit cliffs to the nearest landclass.

The screenshots I've posted are all along a coastline generated from OSM data, and so there are minimal such problems.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Adding cliffs to terragear

Postby Johan G » Mon Apr 15, 2019 2:48 pm

For those wondering where the source went, it can be found here (the clone changed name from flightgear to terragear).

And yes, it looks like this got merged into TerraGear (see commit e2a6d0). :)
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Adding cliffs to terragear

Postby frtps » Tue Apr 16, 2019 2:48 pm

Yes, the code has been merged into next, including also some later code for decent non-procedural texturing of cliffs as well as the shader and effects files. I'm going to work up a wiki page on how to use it soon. Meanwhile I'm happy to answer any questions here if anybody wants to try it out.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Next

Return to Scenery

Who is online

Users browsing this forum: No registered users and 11 guests