Board index FlightGear Development Effects and shaders

Rain on glass

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

Rain on glass

Postby dom_vc10 » Tue Jan 04, 2022 4:14 pm

Hi

I am trying to add the rain affects to an aircraft. I checked out the MD11 and used the following based on what I saw there.

<effect>
<inherits-from>Effects/glass</inherits-from>
<object-name>Windshield</object-name>
</effect>

This shows raindrops nicely on the glass model however there is no movement. I read https://wiki.flightgear.org/ALS_technical_notes#Rain and see that I should add this code but I cannot see where. I looked at back the MD11 for a real life implementation however I do not see where that code is. I tried to take a look at other aircraft but again didn't find it. I am overlooking something I know but what. Do I need to create an .eff file and use that? lost
dom_vc10
 
Posts: 339
Joined: Mon Jul 27, 2020 8:33 am
Location: CZ - LKTB
Version: nightly
OS: Linux Mint 20.2

Re: Rain on glass

Postby wkitty42 » Tue Jan 04, 2022 5:09 pm

maybe take a look at the c172p? i know it has rain that moves in different directions depending various factors...
"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: Rain on glass

Postby legoboyvdlp » Tue Jan 04, 2022 5:12 pm

dom_vc10 wrote in Tue Jan 04, 2022 4:14 pm: I tried to take a look at other aircraft but again didn't find it. I am overlooking something I know but what. Do I need to create an .eff file and use that? lost


You don't need an .eff file -- unless you want to do some changes -- you can just use what's in FGDATA/Aircraft/Generic

The fact you have raindrops showing means the .eff is working

But you need to update the properties that update the splash vector for the shader. It can literally be anything - nasal, prop rules, jsbsim

The MD-11 uses JSBSim -- it lives in this file:
https://github.com/Octal450/MD-11/blob/ ... effect.xml
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: Rain on glass

Postby dom_vc10 » Wed Jan 05, 2022 6:01 pm

Thank you for the advice I will see if I can get my head around it
dom_vc10
 
Posts: 339
Joined: Mon Jul 27, 2020 8:33 am
Location: CZ - LKTB
Version: nightly
OS: Linux Mint 20.2

Re: Rain on glass

Postby erik » Wed Jan 05, 2022 6:12 pm

Currently there is a probleem in next which could cause rain not showing.
Current: Parachutist, Paraglider, Pterosaur, Pilatus PC-9M and variants, ERCO Ercoupe, Fokker Dr.1, Fokker 50, Fokker 100
Less active: Cessna T-37, T-38, Santa Claus. Previous: General Dynamics F-16. Worked on: Wright Flyer
erik
 
Posts: 2244
Joined: Thu Nov 01, 2007 2:41 pm

Re: Rain on glass

Postby Necolatis » Thu Jan 06, 2022 12:56 am

dom_vc10 wrote in Tue Jan 04, 2022 4:14 pm:I should add this code but I cannot see where.


Any .nas file in the aircraftw ill do.

Remember to add this line AFTER the code:
splash_vec_loop();
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Rain on glass

Postby dom_vc10 » Thu Jan 06, 2022 1:33 pm

Thanks

I have created a nas file. I have listed the nas file in the main xml file where the other nas files are listed.

Necolatis wrote in Thu Jan 06, 2022 12:56 am:Remember to add this line AFTER the code:
splash_vec_loop();


In the ALS guide the example finishes with ..

Code: Select all
settimer(func(){
        splash_vec_loop();
    }, 1);
}


So splash_vec_loop(); should be added again at the end or moved?
dom_vc10
 
Posts: 339
Joined: Mon Jul 27, 2020 8:33 am
Location: CZ - LKTB
Version: nightly
OS: Linux Mint 20.2

Re: Rain on glass

Postby legoboyvdlp » Thu Jan 06, 2022 3:17 pm

It's better you understand what its doing than blindly copying! Look at what the function is doing -- it sets the properties splash-vector-x, splash-vector-y, splash-vector-z. Then, after it's finished, there's the settimer block, it calls the function splash_vec_loop() over again. It has a delay of 1 second, this means that it's going to call the function after a delay of one second. This is what is known as a recursive function.

However, to get that loop going, to do the first loop, you need to command it to start. This is done by just running splash_vec_loop(); right at the bottom of the file, below the last }.


And again, as I said you can use Nasal, JSBSIM, property rules. You don't have to use the Nasal code, the splash-vector properties simply have to be updated in some way. Personally I prefer the JSBSim method.
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: Rain on glass

Postby Necolatis » Thu Jan 06, 2022 3:46 pm

dom_vc10 wrote in Thu Jan 06, 2022 1:33 pm:So splash_vec_loop(); should be added again at the end or moved?


No, don't add it twice. The code you pasted is fine.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Rain on glass

Postby dom_vc10 » Thu Jan 06, 2022 3:52 pm

legoboyvdlp wrote in Thu Jan 06, 2022 3:17 pm:It's better you understand what its doing than blindly copying!


Sorry I am not trying to blindly copy. I am trying to learn however having 0 experience with this is quite a learning curve so apologies, so my questions may seem dumb. I have spent many hours now reading reading and reading plus trying modelling in blender to create the inner windshield (which I did) and applying the effects (which I again I managed) so it's not for a lack of will. I do hope that any decent changes I can make can be shared to better the aircraft I am working on.

legoboyvdlp wrote in Thu Jan 06, 2022 3:17 pm:And again, as I said you can use Nasal, JSBSIM, property rules. You don't have to use the Nasal code, the splash-vector properties simply have to be updated in some way. Personally I prefer the JSBSim method.

I know I understood this from your post and I took the nasal path because it seemed easier for me personally. I am not asking again how you made it clear I can use either of those. I just was questioning the one comment made to me. Again sorry....
Last edited by dom_vc10 on Thu Jan 06, 2022 4:18 pm, edited 2 times in total.
dom_vc10
 
Posts: 339
Joined: Mon Jul 27, 2020 8:33 am
Location: CZ - LKTB
Version: nightly
OS: Linux Mint 20.2

Re: Rain on glass

Postby dom_vc10 » Thu Jan 06, 2022 3:54 pm

Necolatis wrote in Thu Jan 06, 2022 3:46 pm:
dom_vc10 wrote in Thu Jan 06, 2022 1:33 pm:So splash_vec_loop(); should be added again at the end or moved?


No, don't add it twice. The code you pasted is fine.


Thanks
dom_vc10
 
Posts: 339
Joined: Mon Jul 27, 2020 8:33 am
Location: CZ - LKTB
Version: nightly
OS: Linux Mint 20.2

Re: Rain on glass

Postby legoboyvdlp » Thu Jan 06, 2022 5:09 pm

dom_vc10 wrote in Thu Jan 06, 2022 3:52 pm:
Sorry I am not trying to blindly copy. I am trying to learn however having 0 experience with this is quite a learning curve so apologies, so my questions may seem dumb. I have spent many hours now reading reading and reading plus trying modelling in blender to create the inner windshield (which I did) and applying the effects (which I again I managed) so it's not for a lack of will. I do hope that any decent changes I can make can be shared to better the aircraft I am working on.


No worries and my apologies for the way I phrased it -- I was just trying to explain the why behind the answer rather than just answering the question directly!
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: Rain on glass

Postby Necolatis » Thu Jan 06, 2022 5:13 pm

dom_vc10 wrote in Thu Jan 06, 2022 3:54 pm:Thanks


No, wait. The code you pasted is from within the function.

You need to have this code:
Code: Select all
var splash_vec_loop = func(){
    var airspeed = getprop("/velocities/airspeed-kt");

    # f16
    var airspeed_max = 120;

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

    airspeed = math.sqrt(airspeed / airspeed_max);

    var splash_x = -0.1 - 2 * 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);
}

splash_vec_loop();
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Rain on glass

Postby dom_vc10 » Thu Jan 06, 2022 9:17 pm

Necolatis wrote in Thu Jan 06, 2022 5:13 pm:
dom_vc10 wrote in Thu Jan 06, 2022 3:54 pm:Thanks


No, wait. The code you pasted is from within the function.

You need to have this code:
Code: Select all
var splash_vec_loop = func(){
    var airspeed = getprop("/velocities/airspeed-kt");

    # f16
    var airspeed_max = 120;

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

    airspeed = math.sqrt(airspeed / airspeed_max);

    var splash_x = -0.1 - 2 * 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);
}

splash_vec_loop();


Yes I understood I need the whole code I was just clarifying your comment on splash_vec_loop(); :)


legoboyvdlp wrote in Thu Jan 06, 2022 5:09 pm:
No worries and my apologies for the way I phrased it -- I was just trying to explain the why behind the answer rather than just answering the question directly!


No problem I should have not taken it like I did, just getting frustrated trying to make things work :D
dom_vc10
 
Posts: 339
Joined: Mon Jul 27, 2020 8:33 am
Location: CZ - LKTB
Version: nightly
OS: Linux Mint 20.2

Re: Rain on glass

Postby dom_vc10 » Thu Jan 06, 2022 10:49 pm

wkitty42 wrote in Tue Jan 04, 2022 5:09 pm:maybe take a look at the c172p? i know it has rain that moves in different directions depending various factors...


Wellllll in the end I used that. I figured out I need to add to the main.xml and a copy in my systems folder and it works. Just need to tweak it so the rain slowly drops down when stationary and maybe more, I will see how I go.


@legoboyvdlp - So in the end I am using jbsim (I noticed a comment in the wiki the nasal is not the best) :lol:

Thanks all for the advice all, very much appreciate it :wink:

Next mask for windscreen wipers.... :shock:
dom_vc10
 
Posts: 339
Joined: Mon Jul 27, 2020 8:33 am
Location: CZ - LKTB
Version: nightly
OS: Linux Mint 20.2


Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 6 guests