Board index FlightGear Development Weather

Aircraft in shadow when flying over clouds

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

Aircraft in shadow when flying over clouds

Postby dutchguy » Tue Aug 04, 2015 4:46 pm

Hi all,

Today I noticed something odd. I was flying at FL400, with scattered cumulus clouds below me, and clear skies above. Hence I'd expect the aircraft to be in sunshine all the time, but when I was above a cloud, the specular reflections disappeared, and reappeared once I wasn't over the cloud anymore. Could it be that the algorithm that decides whether to show specular reflection doesn't know at what altitude the plane flies? And if so, does anyone know in what part of the code this could be changed? Then perhaps I can try to change it.
dutchguy
 
Posts: 108
Joined: Mon Mar 31, 2014 5:16 pm

Re: Aircraft in shadow when flying over clouds

Postby Thorsten » Tue Aug 04, 2015 6:26 pm

Congratulations! I was actually wondering whether someone would notice at all. Since it has taken more than a year, I guess it's pretty safe not to waste the framerate on a fix.

(The algorithm knows the altitude of the plane alright, it just doesn't know the altitude of the cloud).
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Aircraft in shadow when flying over clouds

Postby dutchguy » Wed Aug 05, 2015 12:51 pm

Would it really cost that much framerate? My naive guess would be that it's just one if-statement, and that since the algorithm knows the position of the clouds, it shouldn't cost that much extra to know the altitude as well.
dutchguy
 
Posts: 108
Joined: Mon Mar 31, 2014 5:16 pm

Re: Aircraft in shadow when flying over clouds

Postby Thorsten » Wed Aug 05, 2015 1:15 pm

My naive guess would be that it's just one if-statement, and that since the algorithm knows the position of the clouds, it shouldn't cost that much extra to know the altitude as well.


First, if-statements in GLSL tend to be not simple and often unexpectedly expensive since frequently both branches are evaluated, so the cost of if (A==0) {do something cheap;} else {do something expensive;} might end up (something cheap + something expensive) regardless of the value of A.

Second, the cloud position isn't known by the algorithm, it is assembled, encoded and passed via the effect framework where it is decoded in the OpenGL shader. There's no obvious free slot in the procedure to encode something more, so you need to pass more parameters - about 30 more in fact, or about 20% more.

Third, there's no one place where all this is done - cloud shadow computation is pretty de-localized, partially done by the weather system, partially done by the ALS GLSL shaders (yeah, pretty much all of them because the computation needs to be in each of them).

So your naive guess couldn't be further from the actual situation.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Aircraft in shadow when flying over clouds

Postby wkitty42 » Wed Aug 05, 2015 8:54 pm

Thorsten wrote in Tue Aug 04, 2015 6:26 pm:Congratulations! I was actually wondering whether someone would notice at all. Since it has taken more than a year, I guess it's pretty safe not to waste the framerate on a fix.

(The algorithm knows the altitude of the plane alright, it just doesn't know the altitude of the cloud).

myself and someone else talked about this in some topic a month or two ago... i don't recall which topic it was, though... i'm pretty sure it was before the freeze... possibly after the first c172p import into fgdata...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04


Return to Weather

Who is online

Users browsing this forum: No registered users and 3 guests