Board index FlightGear Media

Flightgear and Unity3D

Screenshots, videos, sound recording etc. taken in/with FlightGear.

Flightgear and Unity3D

Postby chriscalef » Thu Apr 04, 2013 3:46 am

Hey everybody,

From the "warped and twisted uses to which no one ever expected Flightgear to be put" department: I'd like to share a few screenshots demonstrating a little system I just put together. My ultimate goal here is a real-world-terrain-based MMO game using Unity for the FPS engine and FlightGear as a backend skybox server. I also have goals for this technology that go far beyond games, but I'll leave that for later discussions.

For now, on to the screenshots!

Image

This is standing on Spencer Butte in Eugene, Oregon, looking west. The next one is looking south:

Image

This one is is down in south Eugene, looking up at Spencer Butte.

Image

And here's one up in the Coburg Hills north of town, looking south back toward Eugene:

Image

This is west of Eugene, watching the sun set tonight. Also, the first one starting to add things like Unity's trees into the foreground. Still very much programmer art on that end.

Image


This is all done using Unity C# scripts, opening up sockets to communicate with A) a tiny little terrain server I wrote in C++, which accepts a starting latitude/longitude and a width/height of the area, and returns height data from a giant ten-meter-resolution height data file I made from DEM maps. In Unity I have a 3x3 set of tiny terrains (640m each) which page across the landscape, loading new data and moving as necessary to stay in front of the player. And then, B) a modified flightgear instance, which takes a socket connection from which it reads latitude, longitude, and elevation, and returns five screenshots taken at 90 degree angles to each other, with a 90 degree field of view.

The result was actually better than I expected, although the lighting comes out pretty sharply different between the different camera angles. There is no hiding the fact that I'm painting to a skybox - but for a first pass, it's actually pretty entertaining anyway. :-)

There are several flightgear related tasks remaining to figure out. (Warning, gross understatement.) It would work much better if I could somehow turn off rendering for everything within a certain radius of the camera, so I would not accidentally fill half my sky with one tree. :-P The best solution would be to somehow cut out the exact square that I'm rendering locally in Unity, but I'm quite willing to accept cheap hacks and half measures at this point.

I also need to figure out a quick & easy way to raycast for a terrain height at any given place in the flightgear world. And figure out enough of terragear to know how the terrain textures are placed. And on and on and on... but I thought some folks here might get a laugh out of this little project, at least.

Cheers, and thanks so much to everyone who's helped make Flightgear what it is!

Sincerely,
Chris Calef, CTO
BrokeAss Games, LLC
chriscalef
 
Posts: 276
Joined: Wed Feb 20, 2013 9:28 pm

Re: Flightgear and Unity3D

Postby Bjoern » Thu Apr 04, 2013 1:07 pm

Promising, although I am no fan of fantasy stuff at all.
Bjoern
 
Posts: 469
Joined: Fri Jan 06, 2012 10:00 pm
Location: TXL or so
Version: Next
OS: ArchLinux, Win 10

Re: Flightgear and Unity3D

Postby Hooray » Thu Apr 04, 2013 2:33 pm

I don't quite understand what you are doing there technically - i.e. the various components you are integrating there and their roles. What exactly is FG doing, and what is it that Unity3D is doing ? And how is this useful ? (Sorry for asking the obvious).
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: Flightgear and Unity3D

Postby chriscalef » Thu Apr 04, 2013 2:38 pm

Oh, me neither! Sorry, I could have clarified a bit more. They guy with the axe is one of the stock two characters that ships with the fantasy-looking MMOKit for Unity, but he won't be anywhere near my final project, he's just in there for scale and to have a player at this early stage. The MMO game I'm personally interested in making is more of a near future post-apocalyptic genre, actually.

I would also like to make this skybox/terrain mechanism available to others, however, for many different types of projects.

Part of my plan here is to go off on a fork of terragear et al, at whatever level is necessary to change the interpretation of the GIS data, eg to substitute something more blasted and smoking where the urban areas are in the current flightgear world. Once I get that handled I plan to use GIS shapefiles as a format for creative game-related mapping work, so we're not limited to just the existing real world data, but can paint towns and roads wherever we want.
chriscalef
 
Posts: 276
Joined: Wed Feb 20, 2013 9:28 pm

Re: Flightgear and Unity3D

Postby kyokoyama » Thu Apr 04, 2013 5:09 pm

So, in a nutshell, you're trying to port all FG resources and data (terrain, sky/atmosphere, maybe even airport data?) into the Unity engine?
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: Flightgear and Unity3D

Postby chriscalef » Thu Apr 04, 2013 5:32 pm

Not exactly... what I'm primarily doing is using flightgear to draw skyboxes for the Unity (or other FPS style) engine.

All I get out of flightgear is five textures, which draw to the front, back, sides and top of the skybox. The local terrain in Unity I'm actually handling on my own, at much higher resolution than flightgear's terrain (10m instead of 90m(?) for flightgear), although I would like to figure out how to also export the terrain height data from flightgear for the rest of the world beyond my current 50km area of high res data.

I would also like to be able to lift the terrain texture for a given area out of flightgear and inform Unity of it, but I'm taking it one step at a time...

There may be some overlap when it comes to objects - I may end up converting some of the .ac files in flightgear into FBX or collada, so I can load them into Unity, but more often I think I'll be going the other way and adding my FBX game models into flightgear, ala this thread.

As it is now, though, I can run and run across 2500 square km of area, and wherever I go I can refresh the skybox to see flightgear's view of my position. Only a very limited region of terrain has to be actually instantiated in Unity at any given time.
Last edited by chriscalef on Thu Apr 04, 2013 5:43 pm, edited 1 time in total.
chriscalef
 
Posts: 276
Joined: Wed Feb 20, 2013 9:28 pm

Re: Flightgear and Unity3D

Postby chriscalef » Thu Apr 04, 2013 5:40 pm

@Hooray: Sorry, missed your post there. Let me know if my last post didn't answer your question.

Long story short, it's useful because I want to create a first person MMO game based in real life terrain, and I want to leverage flightgear's very long view distances, awesome weather and day/night simulation, GIS-based terrain texturing, tree shaders, etc. to give the player the sense of truly being immersed in a planetary scale game environment. And, ultimately, to let them play the game right in their own home town, when I get all the parts put together.

I'm really aiming larger than just making a single game here, though. Ultimately I would like to make this into an open source simulation tool / online metaverse explorer that could be used for many different purposes.
chriscalef
 
Posts: 276
Joined: Wed Feb 20, 2013 9:28 pm

Re: Flightgear and Unity3D

Postby chriscalef » Thu Apr 04, 2013 5:42 pm

It's also in no way locked to Unity, that's just the environment I'm focusing on right now, due to its ease of cross platform export, among other things. I have already written a terrain pager in Torque, and could just as easily pipe these skybox images there, which would result in a 100% open source solution... but only for windows or possibly Mac at the moment, no linux.
chriscalef
 
Posts: 276
Joined: Wed Feb 20, 2013 9:28 pm

Re: Flightgear and Unity3D

Postby Hooray » Thu Apr 04, 2013 6:12 pm

okay, thanks for the info - obviously just asking, because I'm primarily interested in the FG side of things - i.e. questions like "How could this possibly help FG" ? :lol:
Seriously, it would be great to find a way to collaborate to the greatest degree possible here - i.e. by finding common goals and approaches, i.e. to also improve our scenery. Obviously, that would require code being written in C/C++, cross-platform (i.e. not Windows specific) and GPL'ed or some compatible license. Otherwise, the only sensible option would be interfacing via networking code or some other form of IPC.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11783
Joined: Tue Mar 25, 2008 8:40 am

Re: Flightgear and Unity3D

Postby chriscalef » Thu Apr 04, 2013 6:24 pm

Thanks for asking! The main benefit I see here for FG is potentially bringing in a lot more people who would be interested in improving the flightgear scenery.

Re: the GPL and licensing issues, the way I have it designed at the moment is all over a TCP/IP socket, so we should be pretty much free and clear - the flightgear end stays GPL, and the other end doesn't have to really care, it just sends a world position and gets textures back through the socket.

I do intend to release my code on the Unity end as well, however. If this goes where I want it to it is going to be far too big for me to handle on my own. I'm not sure how the legalities come out when you are open sourcing C# code written for Unity, however, is it technically "linked" to the main Unity Engine code even though I have no access to that? Or is there a line there between my C# "scripts" and the main engine code, so I can GPL my scripts without worrying about the main engine code?

I guess I'll leave that to the lawyers, but my main point is I want to make both ends of this an open project, to the maximum extent possible.
chriscalef
 
Posts: 276
Joined: Wed Feb 20, 2013 9:28 pm

Re: Flightgear and Unity3D

Postby Thorsten » Fri Apr 05, 2013 6:37 am

The result was actually better than I expected, although the lighting comes out pretty sharply different between the different camera angles. There is no hiding the fact that I'm painting to a skybox - but for a first pass, it's actually pretty entertaining anyway.


That is probably peculiar for the rendering scheme where the light in the whole scene changes with the view vector. I doubt Atmospheric Light Scattering would do that.

There are several flightgear related tasks remaining to figure out. (Warning, gross understatement.) It would work much better if I could somehow turn off rendering for everything within a certain radius of the camera, so I would not accidentally fill half my sky with one tree. The best solution would be to somehow cut out the exact square that I'm rendering locally in Unity, but I'm quite willing to accept cheap hacks and half measures at this point.


Rendering is done for a near camera and a far camera anyway, so I think all you need to do is not to render the near camera, and that's it... (I think this was specified somewhere in camera_group.cxx ).

Alternatively, you can insert a discard(); statement based on a distance cut into the fragment shaders you're using, this will also not render anything closer than a given distance. If you have a routine which gives you the box to discard in FG world coordinates, it should be possible to discard exactly that box as well.

The local terrain in Unity I'm actually handling on my own, at much higher resolution than flightgear's terrain (10m instead of 90m(?) for flightgear), although I would like to figure out how to also export the terrain height data from flightgear for the rest of the world beyond my current 50km area of high res data.


FG custom scenery can and does actually handle 10 m sized terrain mesh resolution. From the ground, you don't actually need 120 km visibility, 20-40 km will usually do just fine, so this is completely unproblematic to render. And we have cm-sized resolution for terrain textures in 2.11 as well - so your character could be walking on this

Image

which *cough* looks quite competitive to what he's walking on.

Part of my plan here is to go off on a fork of terragear et al, at whatever level is necessary to change the interpretation of the GIS data, eg to substitute something more blasted and smoking where the urban areas are in the current flightgear world.


That can be done at the simple expense of editing the texture to landclass mapping in materials.xml. Instead of random building groups, you can also define random particle systems there which would generate columns of smoke.
Thorsten
 
Posts: 11605
Joined: Mon Nov 02, 2009 8:33 am

Re: Flightgear and Unity3D

Postby chriscalef » Fri Apr 05, 2013 5:37 pm

Wow, THANKS THORSTEN!! =-) That was exactly the kind of help I needed! I will dig in and see what I can do with it.

And yes, *hack*, *cough* what he's standing on is definitely untouched programmer art... Unity can do much, much better, of course, but I was focusing on the skybox for this early demo. VERY good to know that we can get those higher terrain and texture resolutions out of flightgear, however!

"Texture to landclass mapping in materials.xml", got it, again thank you very much!!
chriscalef
 
Posts: 276
Joined: Wed Feb 20, 2013 9:28 pm

Re: Flightgear and Unity3D

Postby chriscalef » Sat Apr 06, 2013 8:01 am

@Thorsten: could you perchance elaborate on this statement?

That is probably peculiar for the rendering scheme where the light in the whole scene changes with the view vector. I doubt Atmospheric Light Scattering would do that.


How exactly would I switch to the Atmospheric Light Scattering rendering scheme?
chriscalef
 
Posts: 276
Joined: Wed Feb 20, 2013 9:28 pm

Re: Flightgear and Unity3D

Postby Thorsten » Sat Apr 06, 2013 11:38 am

It's a checkbox in the rendering options. The controlling property if you start FG from the commandline is /sim/rendering/shaders/skydome .
Thorsten
 
Posts: 11605
Joined: Mon Nov 02, 2009 8:33 am

Re: Flightgear and Unity3D

Postby chriscalef » Sat Apr 06, 2013 7:52 pm

Aha, that seems to have fixed that problem, thank you very much! Corners are looking much better now.

Will let ya know when I get to the near visibility thing.
chriscalef
 
Posts: 276
Joined: Wed Feb 20, 2013 9:28 pm

Next

Return to Media

Who is online

Users browsing this forum: No registered users and 1 guest