Board index FlightGear Development Spaceflight

Earthview - an orbital terrain rendering engine [v2.0]

Discussion about development and usage of spacecraft

Earthview - an orbital terrain rendering engine [v2.0]

Postby Thorsten » Thu Mar 15, 2012 9:04 am

Who ever said this is difficult? It took me four hours to bring it to this stage - it's a simple textured sphere which (to avoid all sorts of clipping) is about 50 km large but is repositioned using simply ray optics to give it the correct size appearance, has a shader which never fogs and always uses full light intensity and is otherwise administered by a simple Nasal loop.

Framerates are well above 100 (just a single object in view...) and it matches well with the skydome shader. The only stumbling block are skydome rendering artefacts at high altitudes....

Image

Image

Image

Now it needs some math to get it automatically rotated correctly, then a bit higher terrain resolution would do nicely, and then a cloudsphere rendered on top with the same technology would be nice (textures are taken from Celestia - it's not clear to me if the set can be GPL or not...)


Edit: Here is a link to the download of the version 0.1. Earth textures are by 'Jestr' from Celestia and licensed Creative Commons license CC BY-NC-ND, cloud textures are likewise Celestia, done by John van Vliet and are licensed Creative Commons CC-BY-SA.

To install:

1) Unpack the package in FGROOT - this doesn't overwrite any defaults
2) Add the 'earthview' menu item to the menu: Edit gui/menubar.xml to insert

Code: Select all
<item>
         <label>Earthview</label>
         <binding>
            <command>dialog-show</command>
            <dialog-name>earthview</dialog-name>
         </binding>
      </item>


where you like it (I added this under 'View' just below 'Stereoscopic View Options')
When used in-sim, this brings up a very simple gui with 'Start' 'Stop' and 'Cancel' - 'Start' loads an Earthsphere (this might take a few moments, lots of textures), 'Stop' unloads it and 'Cancel' closes the dialog.

Now you can go and explore with the ufo.

3) To get rid of high altitude rendering artefacts and make altitudes above 150 km accessible for JSBSim FDMs apply this patch by Ron Jensen:

Code: Select all
diff --git a/src/Environment/atmosphere.cxx b/src/Environment/atmosphere.cxx
index 022ea54..f16005f 100644
--- a/src/Environment/atmosphere.cxx
+++ b/src/Environment/atmosphere.cxx
@@ -18,7 +18,8 @@ ISA_layer(3,  32000,  104986,  868.019,    0.256326, 228.65, -44.50, -0.0028,  -
 ISA_layer(4,  47000,  154199,  110.906,   0.0327506, 270.65,  -2.50,       0,           0),
 ISA_layer(5,  51000,  167322,  66.9389,   0.0197670, 270.65,  -2.50,  0.0028,   0.0008534),
 ISA_layer(6,  71000,  232939,  3.95642,  0.00116833, 214.65, -58.50,  0.0020,   0.0006096),
-ISA_layer(7,  80000,  262467,  0.88628, 0.000261718, 196.65, -76.50),
+ISA_layer(7,  80000,  262467,  0.88628, 0.000261718, 196.65, -76.50,  0.0,      0.0),
+ISA_layer(8,  1.0e9,  3.28e9,  0.00001, 3.0e-9,        2.73, -270.4,  0.0,      0.0),
 };
 
 const int ISA_def_size(sizeof(ISA_def) / sizeof(ISA_layer));


4) To get black background where no skydome is drawn instead of weird fog grey, apply this patch by Lauri

Code: Select all
If you want to try to change the clear color to black, you must edit
flightgear/src/Main/renderer.cxx around line  700. There are two
instances of following:
camera->setClearColor(toOsg(clearColor));
which should be changed to
camera->setClearColor(osg::Vec4(0.0, 0.0, 0.0, 0.0));


5) To make Vostok-1 go beyond 150 km altitude, remove the altitude crash condition in Aircraft/Vostok-1/Nasal/Crashes.nas, i.e. comment out the following block:

Code: Select all
if (altitude>maximum_altitude_ft)
      {
         setprop("fdm/jsbsim/systems/crashes/crashed", 1);
         setprop("fdm/jsbsim/systems/crashes/crash-type", "Alititude exceeds "~(maximum_altitude_ft*0.3048/1000)~"km");
         crash("Alititude exceeds "~(maximum_altitude_ft*0.3048/1000)~"km", "Vysota prevysila "~(maximum_altitude_ft*0.3048/1000)~"km");
      }


=> Flightgear is now fully orbit-ready - I've flown a short mission yesterday to 600 km altitude, and this works like a charm and is quite beautiful.

(Hopefully I can persuade people to include these patches to GIT...).

Dear 3d modellers - please take a look at Earth in Models/Astro/ - it's really just a textured collection of sphere sections. I didn't manage to patch this together as well as can probably be done because I am basically just fooling around with ac3d. But for you guys it should be really easy to segment Earth into a finer pattern and apply more detailed Celestia or other textures, to make texture change runtime like a livery and all these things.

Please, please do so! I really just want to get this on the way and then go back to doing weather, because I can't really spend much time on it.
Last edited by Thorsten on Tue Nov 15, 2016 10:36 am, edited 3 times in total.
Thorsten
 
Posts: 10728
Joined: Mon Nov 02, 2009 8:33 am

Re: Earthview - an orbital terrain rendering engine

Postby Thorsten » Thu Mar 15, 2012 8:37 pm

And... voila - fully functional (I probably spent more time arguing with vitos than implementing this - which is revealing in itself). Doubled the texture resolution and added a cloud layer - this is now equivalent to Celestia level 3 textures, It's nice up here... now we just need a real spacecraft to make it high enough (the Vostok makes only 150 km altitude, here I am probably more than 1000 km high)

The Tibetan plateau:

Image

There's sunrises and sunsets...

Image

This is Iran (I think...), recognizing where you are in unfamiliar orientation is a bit tricky.

Image

Pale blue marble from really far out (the skydome shader bends light in a funny way - probably finally the numerics becomes unstable, nothing in Flightgear was really designed for this)

Image

I headed back to Earth, targeted Corsica, the model made an automatic transition to default Flightgear at about 50 km altitude, to my joy I was in Corsica, but it was... changed. Somehow the clouds were confused about what the reference plane for their proper orientation is (Stuart, any idea?), and the terrain had some issues. I don't really have an explanation, except that going 30.000 km away from Earth I might have picked up all kinds of numerical problems on the way.

Image

Well, some quirks to be sorted out. But basically this works great.
Thorsten
 
Posts: 10728
Joined: Mon Nov 02, 2009 8:33 am

Re: Earthview - an orbital terrain rendering engine

Postby HHS » Thu Mar 15, 2012 8:57 pm

Thorsten wrote in Thu Mar 15, 2012 8:37 pm:...
I headed back to Earth, targeted Corsica, the model made an automatic transition to default Flightgear at about 50 km altitude, to my joy I was in Corsica, but it was... changed. Somehow the clouds were confused about what the reference plane for their proper orientation is (Stuart, any idea?), and the terrain had some issues. I don't really have an explanation, except that going 30.000 km away from Earth I might have picked up all kinds of numerical problems on the way.

Well, some quirks to be sorted out. But basically this works great.


Sure you didn't enter a wormhole?

Did I understand right that the whole earth here is just a simple textured 3d-object? Does it overlay the terrain we do know?

Looks impressive...
Up, up and away
User avatar
HHS
Retired
 
Posts: 3624
Joined: Thu Jul 19, 2007 8:09 am
Version: GIT

Re: Earthview - an orbital terrain rendering engine

Postby longfly » Thu Mar 15, 2012 9:02 pm

wow, this looks cool ;)

great work
Longfly
User avatar
longfly
 
Posts: 229
Joined: Tue Dec 07, 2010 4:41 pm
Location: EDDM (Germany)
Version: always new

Re: Earthview - an orbital terrain rendering engine

Postby kyokoyama » Thu Mar 15, 2012 9:12 pm

Image

The atmosphere distortion glitch and the terrain failure actually seems really cool! ...kinda like some sort of sci-fi movie where you end up in an alternate universe or something.

That aside, this is really amazing! Great job, as always!

PS: Your picture shows Iran and Afghanistan on the top right, Russia on top, Iraq, Saudi Arabia and Kuwait on your right, Azerbaijan around the middle, and... .... yeah, that's all I can tell for now. :P
Look for "B-BIRD" "N127KY" or "AVA0004" -that's me.

Despite having over 1700 posts here, I am not even close to being the most skilled guy here... I'm just words and bad drawing, not experience. :P
kyokoyama
 
Posts: 1988
Joined: Sun May 03, 2009 2:16 am
Location: Earth
Callsign: B-BIRD, N127KY
Version: 2.12.1
OS: Windows Vista

Re: Earthview - an orbital terrain rendering engine

Postby Thorsten » Fri Mar 16, 2012 10:21 am

Did I understand right that the whole earth here is just a simple textured 3d-object?


Yes.

Does it overlay the terrain we do know?


Technically, at 1000 km altitude there isn't really any default terrain loaded, everything farther than 120 km is clipped in any case. This prevents us from simply using a textured sphere - most of it would never be shown.

The earthsphere is a 50 km diameter sphere floating between the normal terrain and the spacecraft, constantly re-positioned and turned to give you the illusion that it is the real thing - and in the absence of fog, you really can't tell, so the illusion is perfect.

The sphere is made slightly larger than real Earth, so once you descend, you pass its boundary at some point, it's invisible from the inside and you're left with the normal terrain. Or what's left of it - see above
Thorsten
 
Posts: 10728
Joined: Mon Nov 02, 2009 8:33 am

Re: Earthview - an orbital terrain rendering engine

Postby kyokoyama » Fri Mar 16, 2012 5:52 pm

How is the transition between that globe model and regular scenery like, then?
Also, does the Earth look weird at all with all that constant readjusting if you change the zoom level? (i.e. -if you zoom out so that your FOV is 120 degrees, then change your orientation, will the earth and atmosphere not match?)
Look for "B-BIRD" "N127KY" or "AVA0004" -that's me.

Despite having over 1700 posts here, I am not even close to being the most skilled guy here... I'm just words and bad drawing, not experience. :P
kyokoyama
 
Posts: 1988
Joined: Sun May 03, 2009 2:16 am
Location: Earth
Callsign: B-BIRD, N127KY
Version: 2.12.1
OS: Windows Vista

Re: Earthview - an orbital terrain rendering engine

Postby Thorsten » Fri Mar 16, 2012 7:02 pm

How is the transition between that globe model and regular scenery like, then?


The earthsphere is currently a bit (30 km or so) larger than real terrain. Well, actually it is 300 m larger and optics does the rest. So you are inside of if when you're below 30 km and don't see it. In the future, I probably simply fade it to transparent at a user-selected altitude by shader magic. Anyway, it doesn't matter for a 1000 km orbit if you're really 970 km above the surface, there's no way you can guess this accurately.

Also, does the Earth look weird at all with all that constant readjusting if you change the zoom level? (i.e. -if you zoom out so that your FOV is 120 degrees, then change your orientation, will the earth and atmosphere not match?)


Short of separating camera position from aircraft position by a distance of several km, the scheme is exact - each light ray always hits the earthsphere under the same ange where it would hit real the real thing, i.e. every pixel is always painted correcty. Without fog, you can't gauge any distance, so there is no way you can ever uncover the illusion being in the spacecraft. My implementation is a bit flawed since I couldn't position the sphere exactly at the origin - I'm a percent off or so :(

The tower view would potentially reveal what is going on though... but only if the tower is outside the earthsphere, i.e. if the spacecraft is more than 5000 km away from the tower - and then there's no real reason to use tower view any more.

It's a bit like with the skydome - it's 'really' just 20 km or so away from the aircraft - there's just no way you can see this, because it moves with the view and there is no size reference.

I'm actually quite proud of the scheme - especially of having figured out the rotations needed to put you above your location by twisting imaginary airplanes in my head.
Thorsten
 
Posts: 10728
Joined: Mon Nov 02, 2009 8:33 am

Re: Earthview - an orbital terrain rendering engine

Postby Sealbhach » Fri Mar 16, 2012 7:21 pm

This is amazing. I am in awe of our resident Cloudmeister. Once the glitches are all ironed out we need to build a space shuttle!

.
Sealbhach
 
Posts: 942
Joined: Wed Jun 30, 2010 9:17 am

Re: Earthview - an orbital terrain rendering engine

Postby Thorsten » Tue Mar 20, 2012 10:15 am

Ron Jensen provided a patch to overcome the altitude problems in the atmosphere definition, so we can finally seriously fly:

Vostok-1 climbs onto a higher trajectory - here we have 250 km over Nevada...

Image

... and in elliptic orbit over the Pacific Ocean with 250/450 km

Image

I just need to design a crude menu (typing the init commands from the Nasal console may not be everyone's idea of fun) and then people can go and play with it.

Once the glitches are all ironed out we need to build a space shuttle!


Yes please!
Thorsten
 
Posts: 10728
Joined: Mon Nov 02, 2009 8:33 am

Re: Earthview - an orbital terrain rendering engine

Postby DutchPilotMitchell » Tue Mar 20, 2012 1:21 pm

This look promising! Good work mate!
Proud to be Dutch.
User avatar
DutchPilotMitchell
 
Posts: 719
Joined: Tue Feb 15, 2011 9:10 pm
Location: The Netherlands
Callsign: mitchel
Version: 22
OS: Mac OS X

Re: Earthview - an orbital terrain rendering engine

Postby Ernest1984 » Tue Mar 20, 2012 5:10 pm

Maybe a little more resolution on that Eartview, would add some more realism ;)
EPWA-hub: ERJ-195 clsgn: ERNIE
-----------------------------------
Around The World with B1900D!
callsign: AROUNDw - currently suspended till the FG will have a proper look on different locations
User avatar
Ernest1984
 
Posts: 438
Joined: Wed Dec 01, 2010 3:47 pm
Location: Poland / Canada
Callsign: ERNIE
Version: 2.10
OS: Mac OS X 10.8.2

Re: Earthview - an orbital terrain rendering engine

Postby Thorsten » Tue Mar 20, 2012 6:23 pm

Maybe a little more resolution on that Eartview, would add some more realism


Certainly... at the resolution level shown, the whole texture pack is compressed about 100 MB. If we go to the full resolution of level 6 Celestia textures, that should be... about 12 GB of textures (Celestia can use fairly efficiently stored jpg textures - we have to use rgb or png) - there's no way I can host that amount of data for me. Do I sense an offer to host the pack from you? :D
Thorsten
 
Posts: 10728
Joined: Mon Nov 02, 2009 8:33 am

Re: Earthview - an orbital terrain rendering engine

Postby kyokoyama » Wed Mar 21, 2012 12:50 am

(I'm not Ernest, but I would volunteer to host, but I doubt a free MediaFire account can handle the bandwidth or package size... :( )
Speaking of which, how did we get to being able to use PNGs along with RGBs in the first place?

If it's not something coming solely from the switch to OSG however long ago that was, is it also possible to use that method to allow the use of JPEGs?
Look for "B-BIRD" "N127KY" or "AVA0004" -that's me.

Despite having over 1700 posts here, I am not even close to being the most skilled guy here... I'm just words and bad drawing, not experience. :P
kyokoyama
 
Posts: 1988
Joined: Sun May 03, 2009 2:16 am
Location: Earth
Callsign: B-BIRD, N127KY
Version: 2.12.1
OS: Windows Vista

Re: Earthview - an orbital terrain rendering engine [v0.1]

Postby Thorsten » Wed Mar 21, 2012 8:16 am

Download link in first post. Needs a bit manual work to get full experience...

I've tried yesterday to take Vostok a bit higher up, and it works like a charm, basically all problems with rendering and atmosphere holes are gone now, and the view is quite spectacular.

Anyone who wants to contribute:

* improve the Earth model - it's just a textured sphere, any 3d modeller should be able to make the seams go away or texture it with higher resolution or even devise a smart texture management which loads with highres just the sheets you're flying over

* Vostok needs some love - sound files need to be converted to be audible again

* a few more spacecraft would be terrific
Thorsten
 
Posts: 10728
Joined: Mon Nov 02, 2009 8:33 am

Next

Return to Spaceflight

Who is online

Users browsing this forum: No registered users and 2 guests