Board index FlightGear Development Effects and shaders

Glass

An exciting "new" option in FlightGear, that includes reflections, lightmaps, the particle system etc.. A lot is yet to be discovered/implemented!

Re: Glass

Postby clrCoda » Sat Aug 01, 2015 2:45 am

But from what I understand of your "wish" you would like to transfer this data from a pilot that has it, thru multiplayer to a pilot that doesn't. Planes and walkers and what have you. Isn't that what we can interpolate from what you said?.

I'm saying that doing so is potentially harmful.
--Ray
Ray St. Marie
clrCoda
 
Posts: 1225
Joined: Wed Apr 07, 2010 12:04 pm

Re: Glass

Postby Thorsten » Sat Aug 01, 2015 9:00 am

if i'm understand this last statement, you are saying that if one person is in a C172P and it has everything implemented and someone else is at the same place at the same time but in a craft that has few or none of these features implemented, the other person won't see things like rain splashed on the water puddles, or even rain on the windows?


The rendering engine doesn't texture airplanes either - that's a job done by the aircraft maintainer because the rendering engine can't know what texture the airplane is supposed to have.

Likewise, the rendering engine can't know that a surface is to represent glass unless you tell it via an effect declaration. It can't know how the airstream goes across the glass unless you tell it via a splash vector. It can't know what the surface structure of the airplane is (in terms of bolts, rough patches,...) unless you tell it via a normal map.

So in general the rendering engine will do what you allow it to (via the rendering controls and the quality selection slider), connected with a logical AND with what is able to do because it has the information.

For instance, if you declare a surface as glass and it is raining, the renderer knows that it should paint a rain pattern and does that, but if you do not specify a splash vector, it doesn't know how the airstream goes across it and never changes the rain pattern as the plane accelerates down the runway. You will always see rain splashes on the runway if the quality setting is high enough, because the runway never changes with the plane you choose and the rendering engine always has the information of the layout.

But we can't pre-suppose that all transparent surfaces represent glass - in many cases (think grilles painted on a texture) they represent air, or semi-transparent surfaces may represent fog (see typical particle textures, or the whole set of cloud textures),... so the renderer needs that information.

Aircraft effects usually need to be implemented per-airplane because they need airplane-specific information, it's as simple as that. And they're optional because not every maintainer wants to go to the same level of visual detail.

We can't actually encode the fact that it is raining into the scene simulation and let the renderer do all the physics - that'd give you still images at a rate of a frame per minute. We need to be much faster, and so it's a game of visual illusions and pre-computing whatever can be pre-computed.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Glass

Postby wkitty42 » Sun Aug 02, 2015 5:57 pm

@lego: i did read the message... i should have hilited this part, "where they have the potential to send me some nasal that rewrites my file structure" as being the part i was saying i didn't think was possible... are you aware of FGFS sending anything other than property tree values over MP?
"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

Re: Glass

Postby wkitty42 » Sun Aug 02, 2015 5:58 pm

Thorsten wrote in Sat Aug 01, 2015 9:00 am:We can't actually encode the fact that it is raining into the scene simulation and let the renderer do all the physics - that'd give you still images at a rate of a frame per minute. We need to be much faster, and so it's a game of visual illusions and pre-computing whatever can be pre-computed.

i understand a little more, now... thank you :)
"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

Re: Glass

Postby Thorsten » Fri Aug 07, 2015 6:35 am

Following a suggestion by Richard, the glass effect now supports a lightmap for reflections, i.e. if your cockpit is lit at night, the reflections in the glass will show this if the lightmap is applied.

Since the reflected scene is a cubemap, the lightmap of it has to be as well. The basic syntax which needs to be added to a derived effect to activate the lightmap is hence

Code: Select all
<use-reflection-lightmap type="int">1</use-reflection-lightmap>
<texture n="4">
     <type>cubemap</type>
     <images>
           <positive-x>Models/Effects/interior/reflection/l004.png</positive-x>     
          <negative-x>Models/Effects/interior/reflection/l002.png</negative-x>   
          <positive-y>Models/Effects/interior/reflection/l001.png</positive-y>     
          <negative-y>Models/Effects/interior/reflection/l003.png</negative-y>   
          <positive-z>Models/Effects/interior/reflection/l006.png</positive-z>     
          <negative-z>Models/Effects/interior/reflection/l005.png</negative-z>     
      </images>
</texture>


The lightmap itself is configured like lightmaps in model-combined.eff are (syntax and code are literally the same).

For instance

Code: Select all
<lightmap-multi type="int">0</lightmap-multi>
<lightmap-factor type="float" n="0">1.0</lightmap-factor>
<lightmap-color type="vec3d" n="0"> 1.0 1.0 1.0 </lightmap-color>


define a single-channel lightmap in which color of a pixel encodes the color of light, and lightmap-factor then encodes the light intensity (make that use a property to have runtime control over the light).

Since mixing reflected, refracted, transmitted and scattered light on glass is somewhat tricky, I'm not completely sure about the light balance. Illuminated reflections will be shown stronger at night dependent on outside and inside intensity and glass reflectivity - just let me know whether the effect is flexible enough to get what aircraft maintainers need.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Interior shading

Postby tigert » Fri Aug 07, 2015 9:02 am

I am not sure if this can be done already with the current tools, but it would be nice if using the heater/blower would defrost and de-fog the window with a map so that the window clears first near the air outlet before doing so completely. And given extreme enough conditions, the heater could be powerful enough to clear just a small opening for you to peek through :P
tigert
 
Posts: 106
Joined: Sat Nov 08, 2014 10:57 am

Re: Glass

Postby dtlan201 » Tue Nov 03, 2015 12:17 pm


I can't get the rain works on A330
Here are what I did
add Aircraft/A330-200/Nasal/weather.nas
Code: Select all
    var splash_vec_loop = func {

    var airspeed = getprop("/velocities/airspeed-kt");

    var airspeed_max = 120;

    if (airspeed > airspeed_max) {airspeed = airspeed_max;}

    airspeed = math.sqrt(airspeed/airspeed_max);

    # f-16
    var splash_x = -0.1 - 2.0 * airspeed;
    var splash_y = 0.0;
    var splash_z = 1.0 - 1.35 * airspeed;


    setprop("/environment/aircraft-effects/splash-vector-x", splash_x);
    setprop("/environment/aircraft-effects/splash-vector-y", splash_y);
    setprop("/environment/aircraft-effects/splash-vector-z", splash_z);

    settimer( func {splash_vec_loop() },1.0);
    }


link the nasal file to Aircraft/A330-200/A330-common.xml

Flip the normal of the windshield on A330-200main.ac then on Aircraft/A330-200/Models/A330-animations.xml add
Code: Select all
    <effect>
        <inherits-from>Effects/glass</inherits-from>
      <object-name>Windshield</object-name>
    </effect>

Is there any steps that I missed or did wrong? ( I just need to implement the rain effect only)
dtlan201
 
Posts: 191
Joined: Sun Sep 29, 2013 4:49 am
Callsign: MIA0774
Version: nightly
OS: Windows 10

Re: Glass

Postby ludomotico » Tue Nov 03, 2015 1:05 pm

It seems you never call to the splash_vec_loop() function. You have to call it once, and then it will register itself as a timer (the last command in the function).

For example, add this line to the end of weather.nas (ouside the function definition: that is, this must be the very last line in your weather.nas file)

Code: Select all
splash_vec_loop();


Keep in mind that, most probably, the A330 already has some nasal functions running as a loop. From the point of view of efficiency, it is a good idea to join all these functions together.
User avatar
ludomotico
 
Posts: 1269
Joined: Tue Apr 24, 2012 2:01 pm
Version: nightly
OS: Windows 10

Re: Glass

Postby psadro_gm » Tue Nov 03, 2015 2:03 pm

Just a quick update for you Linux people out there. I upgraded to Fedora 23, which includes a beta x.org server. This means the nvidia blob no longer works ( until x.org creates a release of 1.18 )

Long story short, I am (temporarily) running the OSS nouveau drivers, and I'm getting about 90% of the frame rate as the nvidia blob. Unfortunately, ALS had to be disabled, because there were so many artifacts, but the default rendering engine seemed to be well supported by the driver.
8.50 airport parser, textured roads and streams...
psadro_gm
 
Posts: 751
Joined: Thu Aug 25, 2011 3:23 am
Location: Atlanta, GA USA
IRC name: psadro_*
Version: git
OS: Fedora 21

Re: Glass

Postby MIG29pilot » Tue Nov 03, 2015 4:33 pm

Try closing the windows :wink:
User avatar
MIG29pilot
 
Posts: 1465
Joined: Tue May 19, 2015 5:03 pm
Location: 6 feet under Snow
Callsign: MIG29pilot
Version: 2020.1.3
OS: Windows 10

Re: Glass

Postby dtlan201 » Wed Nov 04, 2015 12:59 am

looks like the code work but only when the battery is ON and the rain seems to splash through the windshield and hit inside the cockpit, somehow it can be seen only at a specific angle.
dtlan201
 
Posts: 191
Joined: Sun Sep 29, 2013 4:49 am
Callsign: MIA0774
Version: nightly
OS: Windows 10

Re: Glass

Postby wlbragg » Wed Nov 04, 2015 1:49 am

@dtlan201, is the A330-200 repo and your code available online to look at?
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7586
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Glass

Postby legoboyvdlp » Wed Nov 04, 2015 2:56 am

wlbragg wrote in Wed Nov 04, 2015 1:49 am:@dtlan201, is the A330-200 repo and your code available online to look at?

Actually, I think he works on a branch of the private repo, on GitLab.
Not too certain.
If you'd like to help, send artix an email.
User avatar
legoboyvdlp
 
Posts: 7981
Joined: Sat Jul 26, 2014 2:28 am
Location: Northern Ireland
Callsign: G-LEGO
Version: next
OS: Windows 10 HP

Re: Glass

Postby dtlan201 » Wed Nov 04, 2015 1:04 pm

They are all above, @wlbragg
dtlan201
 
Posts: 191
Joined: Sun Sep 29, 2013 4:49 am
Callsign: MIA0774
Version: nightly
OS: Windows 10

Re: Glass

Postby wlbragg » Wed Nov 04, 2015 6:12 pm

dtlan201 wrote in Wed Nov 04, 2015 1:04 pm:They are all above, @wlbragg

Nothing I see in that code looks like it should cause your problem. I only asked because I can't be much help without getting hands on to all the code, because some thing may be affecting others and without the entire picture I personally wouldn't have enough information to troubleshoot.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7586
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

PreviousNext

Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 8 guests