Board index FlightGear Development Weather

A local weather system (v1.4 available)

Everything related to weather simulation, visuals should be discussed in the shader subforum.

Re: A local weather system (v1.4 available)

Postby Torsten » Tue Jan 03, 2012 10:29 pm

Just for the records, my two top items on the wish list are:
* less Nasal
* better maintainability of the code
once, that's done: go for new features.

Anyway - thanks for bringing in the best weather simulation, I have ever seen in a flight simulator!

Torsten
flightgear.org - where development happens.
User avatar
Torsten
 
Posts: 648
Joined: Fri Feb 01, 2008 10:22 pm
Location: near Hamburg, Germany
Callsign: offline
Version: next
OS: Linux

Re: A local weather system (v1.4 available)

Postby fredb » Wed Jan 04, 2012 12:58 pm

Gijs wrote in Tue Jan 03, 2012 9:00 pm:With Git from 5 minutes ago. Checked "Enable the local weather module" and pressed OK in Enviroment > Local Weather Settings, then clicked OK in Environment > Local Weather. Not changing/making any settings.

I get the follow Nasal errors:
Code: Select all
Nasal runtime error: non-numeric string in numeric context
  at C:/FlightGear/fgdata/Nasal/local_weather/local_weather.nas, line 589
  called from: C:/FlightGear/fgdata/Nasal/local_weather/local_weather.nas, line 4122
  called from: C:/FlightGear/fgdata/Nasal/local_weather/local_weather.nas, line 3321
  called from: C:/FlightGear/fgdata/Nasal/local_weather/local_weather.nas, line 4244
  called from: C:/FlightGear/fgdata/Nasal/globals.nas, line 100


I pushed a fix but it needs to be checked
User avatar
fredb
 
Posts: 753
Joined: Fri Dec 01, 2006 11:41 am
Location: Paris, France

Re: A local weather system (v1.4 available)

Postby Thorsten » Wed Jan 04, 2012 1:06 pm

Issue seems to be a missing property in Environment/local-weather-defaults.xml - I just checked that my devel version differs from master. I didn't catch it at first even when using FGData master since it is archived, so my user profile did the job correctly.

ground_haze_factor is a property controlling the terrain haze shader which should default to 1.0 if the shader isn't active (which it isn't on GIT). Just removing the listener in line 4258 of local_weather.nas should do the trick and leave it at 1.0, for those who plan to use the haze shader I'll provide a fix this afternoon.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: A local weather system (v1.4 available)

Postby fredb » Wed Jan 04, 2012 1:14 pm

I came across this picture on airliners.net : http://www.airliners.net/photo//1734231 ... 386453cb2c
Image
User avatar
fredb
 
Posts: 753
Joined: Fri Dec 01, 2006 11:41 am
Location: Paris, France

Re: A local weather system (v1.4 available)

Postby Thorsten » Wed Jan 04, 2012 1:14 pm

Just for the records, my two top items on the wish list are:
* less Nasal
* better maintainability of the code


There's now hardly any computing load left in Nasal - I am definitely hitting GPU limits now long before the Nasal computations in the main loop slows me down. 95% of the actual computing which used to be done in Nasal is now either on the shader level or hardcoded.

Don't be deceived by the length of the code - parts of it are plainly obsolete and will be removed over time, other parts are 'art' - some things (good cloud configuration) you can't generalize in a function, you have to design them 'by hand' and simply write that design down in code - which makes for many lines, but no significant computation load.

We can continue to move stuff out of Nasal (the effect volumes for instance could be hard-coded, they're pretty fixed), but it's not going to accelerate anything at this point. Cloud and terrain shaders seem to be the choke points these days.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: A local weather system (v1.4 available)

Postby Thorsten » Wed Jan 04, 2012 1:15 pm

I came across this picture on airliners.net


Tough without actually doing raytracing...
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: A local weather system (v1.4 available)

Postby Gijs » Wed Jan 04, 2012 1:33 pm

fredb wrote in Wed Jan 04, 2012 12:58 pm:I pushed a fix but it needs to be checked

Error is gone. Thanks!
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9544
Joined: Tue Jul 03, 2007 3:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: A local weather system (v1.4 available)

Postby Thorsten » Wed Jan 04, 2012 3:46 pm

Okay, for those who want to continue using the terrain haze shader:

Environment/local-weather-defaults.xml
Nasal/local_weather/local_weather.nas

(also makes the max. visibility range remember user's choice now)...
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: A local weather system (v1.4 available)

Postby Hooray » Wed Jan 04, 2012 4:08 pm

Torsten wrote in Tue Jan 03, 2012 10:29 pm:* less Nasal
* better maintainability of the code


Like Thorsten said already, "less Nasal" can be accomplished by getting rid of old or duplicate code, also the density of code can be increased easily by using some more general solutions. Compared to much of the Nasal library code in $FG_ROOT/Nasal, the LW is somewhat more explicit and verbose and doesn't take any "short cuts". A while ago, I already provided a number of examples to reduce large Nasal loops or function bodies in LW to a more compact form. Some of these examples I added to the Nasal tutorial for future reference.

Thorsten said, rightly, that these are technically more complex (while less verbose though) - I think the most important thing is that Thorsten is able to maintain his own code ;-) so it's obviously his call.
But I'd volunteer to convert some of his code to such a more compact form if he wants to give this a try.

Regarding maintenance, I also share the view that "less Nasal code" is an important ingredient here. But not necessarily "more C++ code" though. If there is Nasal code that shall be moved to C++ space, the "compat_layer.nas" file is probably a good pointer.

Also, I find the LW code getting increasingly "accessible" after being split into separate files ("modules"). So this would probably be one of the easiest ways to improve the maintainability.

Also, some declarative stuff could be moved out of Nasal space into PropertyList XML files and loaded on demand. Also, anything that is related to GUI handling could obviously be moved out of the local_weather directory and directly embedded inside GUI XML files.

I can run LW without any major performance issues here, that's on an i7, 8GB, GX260M notebook. Some issues are quite obviously not related to the Nasal scripts running, but to the Nasal engine itself.

So, for complex Nasal systems, like Thorsten's local weather system or flug's bombable addon, it will probably be worthwhile to eventually look into the core Nasal interpreter, i.e. its known issues (garbage collection): http://wiki.flightgear.org/Improving_Nasal

So I agree with Thorsten here, prematurely optimizing things by moving Nasal code into C++ space just "because C++ is faster" would probably offer very little gain. It took Thorsten quite some time to convince me here, we exchanged quite a number of messages on benchmarking Nasal code and his local weather code in particular, he actually provided a list of likely hot spots, and I couldn't find anything that he didn't know about already.

Scripted code offers certain very real benefits over hard-coded C++ code. Thorsten could develop most of his code without having to go through building FG from source or without having to hack the C++ source code.

We would sacrifice lots of flexibility by moving more and more stuff out of Nasal space into C++ space, just because C++ is somewhat faster. Any Nasal code that is moved to C++ space is unlikely to be easily maintainable by Thorsten any longer. So, I'd be really careful about giving in to that "knee jerk reaction" of reimplementing stuff in C++ just because it feels "more natural" from a core developer's perspective.

Yes, there are huge amounts of Nasal code now, but this isn't to say that Nasal is the primary bottleneck.

Also, Nasal supports more programming styles than the ones currently adopted/used in FlightGear, or in LW in particular.
Multi-threaded programming, and functional programming in particular, are both supported by Nasal, but currently not at all used by any FlightGear scripts. Yet, both of these techniques would have the potential to help complex scripts more or less.

Functional programming in particular, can make scripts much more expressive, dense and succinct. This programming style feels quite natural to any mathematically inclined person. In addition, functional programs have the advantage that concurrency can be exploited more easily.

So there are options available to obtain better performance and maintainability while still keeping code in Nasal space, just by adopting a different programming technique.
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: A local weather system (v1.4 available)

Postby icecode » Wed Jan 04, 2012 4:45 pm

Thorsten wrote:Tough without actually doing raytracing...


Post-processing light scattering can do those rays I think.
icecode
 
Posts: 709
Joined: Thu Aug 12, 2010 1:17 pm
Location: Spain
Version: next
OS: Fedora

Re: A local weather system (v1.4 available)

Postby fredb » Wed Jan 04, 2012 7:14 pm

Thorsten wrote in Wed Jan 04, 2012 3:46 pm:Okay, for those who want to continue using the terrain haze shader:

Environment/local-weather-defaults.xml
Nasal/local_weather/local_weather.nas

(also makes the max. visibility range remember user's choice now)...


Could you tell us why there are 2 pretty similar local_weather.nas in Nasal/ and Nasal/local_weather/ ?
User avatar
fredb
 
Posts: 753
Joined: Fri Dec 01, 2006 11:41 am
Location: Paris, France

Re: A local weather system (v1.4 available)

Postby Thorsten » Thu Jan 05, 2012 8:53 am

Honestly no idea how it slipped in - a mistake in creating the package. Sorry about that, all Nasal files should be contained in

Nasal/local_weather/
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: A local weather system (v1.4 available)

Postby fredb » Thu Jan 05, 2012 9:01 am

so I can delete (remove from git) Nasal/local_weather.nas ?
User avatar
fredb
 
Posts: 753
Joined: Fri Dec 01, 2006 11:41 am
Location: Paris, France

Re: A local weather system (v1.4 available)

Postby Thorsten » Thu Jan 05, 2012 9:07 am

Yes, Nasal/local_weather.nas should be deleted.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: A local weather system (v1.4 available)

Postby chris_blues » Thu Jan 05, 2012 10:57 am

About high altitude visibility and distant clouds; I still think it would be a nice-to-have... This picture is taken @ 25.000 ft above LOWS.
Image
All set like you said, and even at 25.000 ft the clouds kind of disappear in the distance... I think my machine is going to break down, if there were even more clouds to generate, I think, sth more simple could do the trick... Well, I don't know, just giving you guys some input...

Somehow the haze is keeping to fade out on me...
Don't hesitate to let me know if I'm incorrect or just annoying! As long as you do it gently! :)
Debian stable 64bit - i7 8x2.8GHz - 20GB RAM - GeForce GTS 450
Citation II
User avatar
chris_blues
Retired
 
Posts: 1577
Joined: Mon May 03, 2010 2:30 pm
Location: claws of real life
Callsign: chris_blues
Version: GIT
OS: Debian stable 64

PreviousNext

Return to Weather

Who is online

Users browsing this forum: No registered users and 2 guests