Board index FlightGear Development

Big distance object rendering  Topic is solved

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

Big distance object rendering

Postby Gabo » Wed Feb 27, 2013 8:05 am

Hi All.

I'm doing my project which is about displaying airspace borders etc, and FG can't render far objects.

I do generate .ac models + xml files from airspace data, and load these models via nasal code (geo.put_model), BUT these models keep disapearing after a distance..

I do start FG with these parameters
--visibility=200000 --prop:/sim/rendering/camera-group/zfar=200000
it's 200km draw distance, and there is no problem with the terrain rendering
the LOD settings are also insane, detailed is 200000, rough is 400000 and bare is 600000

in the model.xml files I do put a
<animation>
<type>range</type>
<min-m>0</min-m>
<max-m>1000000</max-m>
</animation>

no matter what I do, far ( 80-100km far away) objects keep disapearing despite my settings.
Btw, these airspace sector objects are huge (mostly 10km*10km*3km(height) ) and are drawn fairly normaly at closer distance (under 50k) but do sometimes disapear when I do rotate my camera.

Please help!
Last edited by Gabo on Wed Feb 27, 2013 11:05 am, edited 1 time in total.
Gabo
 
Posts: 20
Joined: Thu Jul 08, 2010 2:04 pm

Re: Big distance object rendering

Postby Thorsten » Wed Feb 27, 2013 9:10 am

I've encountered a similar problem when doing Earthview where I used a textured sphere to represent Earth (and the center of the sphere is more than 6000 km distant).

After some thinking, I've settled for using ray optics to render the model closer but proportionally smaller. Works if you're not fogging it (which I gather you don't want to do). Not sure if that's a solution for you, but I didn't find the switch which made the real earth sphere possible.
Thorsten
 
Posts: 11191
Joined: Mon Nov 02, 2009 8:33 am

Re: Big distance object rendering

Postby zakalawe » Wed Feb 27, 2013 9:12 am

The renderer isn't really designed to deal with rendering things that far away - the 80-120km limits you mention are about what I would expect. You might need to consider more sophisticated techniques, such as custom camera and scene for your airspace boundaries. Although then you have more complex interactions with the sky-dome and clouds, I suspect.

You could scale your geometry down by a factor of 100, again depending on your requirements for interaction with terrain and traffic.
zakalawe
 
Posts: 1152
Joined: Sat Jul 19, 2008 4:48 pm
Location: Edinburgh, Scotland
Callsign: G-ZKLW
Version: next
OS: Mac

Re: Big distance object rendering

Postby Gabo » Wed Feb 27, 2013 11:06 am

In fact I'm willing to modify the FG source and recompile it, if i could pinpoint where is the draw or dont draw logic is located...
Any suggestions?
Gabo
 
Posts: 20
Joined: Thu Jul 08, 2010 2:04 pm

Re: Big distance object rendering

Postby Kabuki » Wed Feb 27, 2013 6:40 pm

Gabo wrote in Wed Feb 27, 2013 11:06 am:In fact I'm willing to modify the FG source and recompile it, if i could pinpoint where is the draw or dont draw logic is located...
Any suggestions?


Please do, although I have no idea what you'd be getting into. This sounds like a basic design issue, where the current system is in spec, and that the specification was made from a practical, "what *can* we do", point of view. Just saying it might be good to throw another set of eyes on the problem.

It's one thing that sorta disappoints me in flightgear, because I like to fly in the Andes and Himalayas, and the way distant objects come into view is not realistic.

Of course, the problem is due to the fact that for any given field of view, the amount of area that needs to be processed increases proportionally. In close, there are only a few objects, out there, there could be many more. I'd thought that was what those cutoff distances were about -- the algorithms used depended on distance. But I already said I don't have any idea. I got my intro to 3d rendering a long time ago, and it's deep stuff. Anybody who can come up with new algorithms is a master chef in my book. Go for it!
This is a family-friendly saloon. No talk stink.
Kabuki
 
Posts: 587
Joined: Fri Oct 23, 2009 11:21 pm
Location: Usually on the ground, always in the sky, except when underwater.
Callsign: Kabuki
Version: 3.0.0
OS: Windows 7

Re: Big distance object rendering

Postby Hooray » Wed Feb 27, 2013 7:14 pm

not sure, the limit was definitely introduced when computers were not yet as powerful, so it would be interesting to see how far we can get by overriding some of these "legacy defaults". But I wouldn't be too optimistic from an approach point of view.

Regarding the whole airspace visualization idea, you may also want to check out this thread: viewtopic.php?f=36&t=19210#p177974

In general, it may make sense to team up with others doing similar things. Having 2-3 guys working on this would surely be a good idea, especially if you have 1-2 people who know C++ and how to build from source.

BTW: The scenery folks were recently talking about some new LOD scheme (see the wiki).
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: 11375
Joined: Tue Mar 25, 2008 8:40 am

Re: Big distance object rendering

Postby fmg » Wed Feb 27, 2013 11:27 pm

Had the same problem not long ago. My object disappeared in about 18 nm distance at low level flight.
80-100 km might have been enough for my propose but I stuck at 18 nm±0.25.
User avatar
fmg
 
Posts: 541
Joined: Tue Jun 29, 2010 5:13 pm
Location: EDDI
Callsign: fotomas
Version: 2
OS: Mac OS X 10.6.8

Re: Big distance object rendering  

Postby Gabo » Wed Mar 13, 2013 7:11 pm

I have found the solution!

There is a function in the source:
SGModelLib::loadPagedModel

it has a line:
plod->setRange(0, 0.0, 50.0*SG_NM_TO_METER);
change 50.0 ( nautical miles (92600 meters) ) to any higher value.

dont forget that commandline options
visibility=200000 --prop:/sim/rendering/camera-group/zfar=200000 must be in sync with the set range.

in CameraGroup::buildCamera
set to this
camera->setCullingMode(/*CullSettings::SMALL_FEATURE_CULLING
| CullSettings::VIEW_FRUSTUM_CULLING*/ CullSettings::VIEW_FRUSTUM_SIDES_CULLING);

FGRenderer::init
set to this
viewer->getCamera()->setComputeNearFarMode(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES/*DO_NOT_COMPUTE_NEAR_FAR*/);

CameraGroup::buildCameraGroup
set to this
bindMemberToNode(gnode, "zfar", cgroup, &CameraGroup::_zFar, 500000.0f);

VisibleSceneInfoVistor()
set to this
setCullingMode(/*CullSettings::SMALL_FEATURE_CULLING
| CullSettings::VIEW_FRUSTUM_CULLING*/ CullSettings::VIEW_FRUSTUM_SIDES_CULLING);
setComputeNearFarMode(CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES/*DO_NOT_COMPUTE_NEAR_FAR*/);

the first plod->setRange is the most important , the other lines may be not important to change...

( Note: set LOD ranges to higher values too! )

You have to recompile the whole code. I'm happy like a kitten :)
Last edited by Gabo on Sat Mar 16, 2013 7:22 pm, edited 1 time in total.
Gabo
 
Posts: 20
Joined: Thu Jul 08, 2010 2:04 pm

Re: Big distance object rendering

Postby Michat » Wed Mar 13, 2013 7:55 pm

Kabuki write down Gabo's name.


Any photo with results?.

Thanks for your awesome work.
User avatar
Michat
 
Posts: 964
Joined: Mon Jan 25, 2010 6:24 pm
Location: Spain
Version: 191b
OS: GNewSense

Re: Big distance object rendering

Postby Gabo » Wed Mar 13, 2013 8:14 pm

here is a screenshot , viewdistance is set to 400km, and we are way above LHBP / Budapest (150+ km altitude)
Image
Gabo
 
Posts: 20
Joined: Thu Jul 08, 2010 2:04 pm

Re: Big distance object rendering

Postby Hooray » Sat Mar 30, 2013 7:11 pm

I have found the solution!

There is a function in the source:
SGModelLib::loadPagedModel
it has a line:
plod->setRange(0, 0.0, 50.0*SG_NM_TO_METER);
change 50.0 ( nautical miles (92600 meters) ) to any higher value.


This could be useful for experimental purposes (local weather, earthview, airspace visualization etc).

But you may want to use a property instead of a hard-coded value here: the property could default to 50nm, but it could be overridden via preferences.xml or via a startup argument using --prop:
You only need to use fgGetDouble(): http://wiki.flightgear.org/Howto:Work_w ... y_Tree_API

It would be a good idea to ask FredB to have a look, because he has previously worked with that code.
And then just file a merge request - which should be safe, because the old behavior would not be changed.
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: 11375
Joined: Tue Mar 25, 2008 8:40 am


Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest