Board index FlightGear Development Aircraft Cockpit development

Glass effect

Discussion about creating 2d and 3d cockpits.

Glass effect

Postby jam007 » Thu May 25, 2017 7:01 pm

The wiki says some background info on glass-effect but no actual example on how to implement it.
How?
jam007
 
Posts: 477
Joined: Sun Dec 16, 2012 10:04 am
Location: Uppsala, Sweden
Version: 2017.3.1
OS: Ubuntu 16.04

Re: Glass effect

Postby Necolatis » Thu May 25, 2017 7:54 pm

You might wanna check out this thread if you haven't:

viewtopic.php?f=47&t=25456
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1987
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: Glass effect

Postby jam007 » Thu May 25, 2017 8:29 pm

Yes I saw that thread but it's discussions are too complicated for me...
I have an inside and an outside pointing glass for the cockpit. How do I implement a basic effect as described here for model-transparent? Is it the same but with:
<inherits-from>Effects/glass</inherits-from>

And should I use <inherits-from>Effects/model-transparent</inherits-from> for the outward pointing glass?
jam007
 
Posts: 477
Joined: Sun Dec 16, 2012 10:04 am
Location: Uppsala, Sweden
Version: 2017.3.1
OS: Ubuntu 16.04

Re: Glass effect

Postby Necolatis » Fri May 26, 2017 12:08 am

This is better for the outward glass I think:

<inherits-from>Effects/model-combined-transparent</inherits-from>

Then you can also get nice reflections and other effects on it.

And yes, use <inherits-from>Effects/glass</inherits-from> for the inward pointing glass.

For example:
Code: Select all
<effect>
  <inherits-from>Effects/glass</inherits-from>
    <parameters>
        <splash-x><use>/environment/aircraft-effects/splash-vector-x</use></splash-x>
   <splash-y><use>/environment/aircraft-effects/splash-vector-y</use></splash-y>
   <splash-z><use>/environment/aircraft-effects/splash-vector-z</use></splash-z>
   <rnorm><use>/environment/rain-norm</use></rnorm>
   <gsnorm><use>/environment/aircraft-effects/ground-splash-norm</use></gsnorm>
   <frost-level><use>/environment/aircraft-effects/frost-level</use></frost-level>
   <fog-level><use>/environment/aircraft-effects/fog-level</use></fog-level>
   </parameters>
   <object-name>inwardsGlass</object-name>
</effect>


Then you can use these properties in <use> above by nasal or some other way, to control what frost, fog, rain is shown.

For example, run this in a nasal loop to get the rain drops running on the glass:
I just used Thorstens f16 vector, due to the glass angle on ja37 being not too different from the f16. (is inverted from Thorsten example though due to normals facing inwards)

Code: Select all
var airspeed = getprop("/velocities/airspeed-kt");
  var airspeed_max = 120;
  if (airspeed > airspeed_max) {
    airspeed = airspeed_max;
  }
  airspeed = math.sqrt(airspeed/airspeed_max);
  # Reverted the vector from what is used on the 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);
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore


Hangar: https://sites.google.com/site/fghangar/
User avatar
Necolatis
 
Posts: 1987
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: Glass effect

Postby Thorsten » Fri May 26, 2017 5:32 am

How do I implement a basic effect as described here for model-transparent? Is it the same but with:
<inherits-from>Effects/glass</inherits-from>


Yes, but model-transparent is a legacy effect - it falls back to a shader-less fixed pipeline function and will look wrong in the details for that reason. Use model-combined-transparent.eff or glass.eff to render glass surfaces instead.
Thorsten
 
Posts: 11087
Joined: Mon Nov 02, 2009 8:33 am

Re: Glass effect

Postby jam007 » Fri May 26, 2017 4:57 pm

Necolatis wrote in Fri May 26, 2017 12:08 am:This is better for the outward glass I think:

<inherits-from>Effects/model-combined-transparent</inherits-from>

Then you can also get nice reflections and other effects on it.

And yes, use <inherits-from>Effects/glass</inherits-from> for the inward pointing glass.

Thanks!
jam007
 
Posts: 477
Joined: Sun Dec 16, 2012 10:04 am
Location: Uppsala, Sweden
Version: 2017.3.1
OS: Ubuntu 16.04


Return to Cockpit development

Who is online

Users browsing this forum: No registered users and 1 guest