Board index FlightGear Development Effects and shaders

Combining Compositor and ALS lights

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

Combining Compositor and ALS lights

Postby erik » Sat Jan 29, 2022 11:41 am

I've worked out a method to combine ALS procedural lights and Compositor lights into one single object using overlays which could be called like this:
Code: Select all
<model>
 <name>StrobeLightR</name>
 <path>Aircraft/PC-9M/Models/Effects/lights/spotlight.xml</path>
 <offsets>
  <x-m>-0.345</x-m>
  <y-m> 5.30</y-m>
  <z-m> 0.68</z-m>
 </offsets>
 <overlay>
  <params>
   <name>StrobeLightR</name>
   <power-source>/sim/model/lights/strobe/state</power-source>
   <direction>
    <x>0</x>
    <y>-1</y>
    <z>0</z>
   </direction>
   <ambient>
    <r>1.0</r>
    <g>1.0</g>
    <b>0.8</b>
   </ambient>
   <specular>
    <r>1.0</r>
    <g>1.0</g>
    <b>1.0</b>
   </specular>
  </params>
 </overlay>
</model>


Unfortunately there is one problem: ALS lights pointing_x, pointing_y and pointing_z are in the opposite direction of Compositor lights <direction><x,y,z>

As they are aliased there is no way to negate one of the two which makes this approach only viable for point lights and not for spotlights.
Does anybody have any clever idea how to solve this?

Erik
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: 2245
Joined: Thu Nov 01, 2007 2:41 pm

Re: Combining Compositor and ALS lights

Postby Thorsten » Sat Jan 29, 2022 12:58 pm

Does anybody have any clever idea how to solve this?


If you want it backward-compatible, introduce a parameter in the effect which is a flag whether to flip direction or not, default to the old solution and set it to 'flip' when your solution is on.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Combining Compositor and ALS lights

Postby erik » Sat Jan 29, 2022 1:24 pm

Good idea, I decided to do something similar:
Add pointing_x, pointing_y and pointing_z support int the compositor code within SimGear.

Erik
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: 2245
Joined: Thu Nov 01, 2007 2:41 pm

Re: Combining Compositor and ALS lights

Postby Thorsten » Sat Jan 29, 2022 2:00 pm

That, too, is a good idea :D
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Combining Compositor and ALS lights

Postby erik » Sat Jan 29, 2022 3:01 pm

In my head this would save unnecessary calculations in the shader.
But I don ´t know if that's true.

Anyhow, I've now added Aircraft/Generic/spotlight.xml and Aircraft/Generic/pointlight.xml which both combine ALS and Compositior lights.

Usage case (for a landing light):
Code: Select all
<model>
 <name>LandingLightL</name>
 <path>Aircraft/Generic/spotlight.xml</path>
 <offsets>
  <x-m>-0.80</x-m>
  <y-m>-1.20</y-m>
  <z-m>-0.06</z-m>
 </offsets>
 <overlay>
  <params>
   <name>LandingLightL</name>
   <power-source>/sim/model/lights/landing-lights/state</power-source>
   <direction>
    <x>1</x>
    <y>0</y>
    <z>0.1</z>
   </direction>
   <ambient>
    <r>1.0</r>
    <g>0.8</g>
    <b>0.6</b>
   </ambient>
   <specular>
    <r>1.0</r>
    <g>1.0</g>
    <b>1.0</b>
   </specular>
   <attenuation>
    <c>0.375</c>
    <l>0.01</l>
    <q>0.0001</q>
   </attenuation>
   <inner_angle type="float">0.1</inner_angle>
   <outer_angle type="float">0.4</outer_angle>
   <zero_angle type="float">0.5</zero_angle>
   <outer_gain type="float">0.0</outer_gain>
   <spot-cutoff>60</spot-cutoff>
   <spot-exponent>45</spot-exponent>
   <dist-scale>10</dist-scale>
   <range-m>1500</range-m>
  </params>
 </overlay>
</model>


Here x, y and z in the direction section correspond to the pointing_x, pointing_y and pointing_z parameters of ALS.

Erik
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: 2245
Joined: Thu Nov 01, 2007 2:41 pm

Re: Combining Compositor and ALS lights

Postby wlbragg » Sat Jan 29, 2022 7:29 pm

What do we gain here, the correct lighting of the environment, such as fog? Is there something else?
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Combining Compositor and ALS lights

Postby erik » Sat Jan 29, 2022 8:43 pm

It is mostly for convenience: to prevent code duplication, within an aircraft and between aircraft. It is just one definition for two light effects.

It also allows both ALS and Compositor lights to move and be directed simultaneously.

Erik
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: 2245
Joined: Thu Nov 01, 2007 2:41 pm

Re: Combining Compositor and ALS lights

Postby erik » Sun Jan 30, 2022 10:51 am

I've added a section about this to the aircraft lights howto in the wiki:
https://wiki.flightgear.org/Howto:Add_aircraft_lights
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: 2245
Joined: Thu Nov 01, 2007 2:41 pm

Re: Combining Compositor and ALS lights

Postby erik » Mon Jan 31, 2022 10:52 am

Per request I've now also added support for pre-ALS sprite lights in 2020.3.
This makes the code forward and backwards compatible between releases (next and 2020.3.12 and later)

Erik
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: 2245
Joined: Thu Nov 01, 2007 2:41 pm

Re: Combining Compositor and ALS lights

Postby scarymovie » Wed Mar 29, 2023 4:15 pm

Hi erik, great work there. I would like to implement this on the CRJ 700. It is currently built to use compositor lights which is not supported in the current stable version. Besides referencing to the mentioned xml, is there anything else to do to make the combination happens?

Thank you.
scarymovie
 
Posts: 214
Joined: Wed Nov 21, 2007 3:34 pm
Location: Singapore


Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 8 guests