Board index FlightGear Development Effects and shaders

ALS aircraft lights

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

ALS aircraft lights

Postby Thorsten » Fri Jul 29, 2016 6:07 pm

Proof of concept for some new ALS technique:

Image

(Note: It's a trick, but as every so often, it ought to cover 95% of use cases)
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: ALS aircraft lights

Postby Harald » Sat Jul 30, 2016 6:38 pm

Very cool. Now we need the same for the aircraft geometry ;)
Harald
 
Posts: 179
Joined: Fri Mar 02, 2007 5:30 pm
Location: Strasbourg, France
Version: nightly
OS: Windows 10

Re: ALS aircraft lights

Postby punkepanda » Sat Jul 30, 2016 11:02 pm

Looks interesting.. Will it respond to flashlight also?
punkepanda
 
Posts: 234
Joined: Mon Nov 04, 2013 10:11 pm
Callsign: LostFlight
Version: 2.12
OS: Arch Linux

Re: ALS aircraft lights

Postby Thorsten » Sun Jul 31, 2016 6:26 am

Very cool. Now we need the same for the aircraft geometry


It's already there and called 'lightmap' - just needs to be used :-)

Will it respond to flashlight also?


Yes.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: ALS aircraft lights

Postby Thorsten » Sun Jul 31, 2016 7:16 pm

Sitting on the launchpad with floodlights illuminating the Shuttle:

Image

Now it's the fierce SRB flame light illuminating the Shuttle:

Image

In fact, if it's dark enough, the glare lights up the clouds for miles and miles:

Image

The SSME flames are much darker and barely illuminate the rear section of the orbiter and ET:

Image
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: ALS aircraft lights

Postby lomar » Sun Jul 31, 2016 8:14 pm

so, how to implement it? is it just a matter of adding some extra lines of code? or the whole shader needs to be reworked?
Anyway, you're a genius, man( with a somewhat tough personality, but still a genius)!
lomar
 
Posts: 479
Joined: Mon Jun 30, 2014 2:38 am
Location: Rio de Janeiro, Brazil
Callsign: lomar
Version: nightly
OS: win 10

Re: ALS aircraft lights

Postby punkepanda » Sun Jul 31, 2016 9:40 pm

Thorsten wrote in Sun Jul 31, 2016 7:16 pm:In fact, if it's dark enough, the glare lights up the clouds for miles and miles:

Awesome..
Soon to beat Rembrandt, even different approach!

Still two questions regarding the limitations of it:
1. Is it somehow possible to make this work over multiplayer?
2. Is it tied to the aircraft itself or can it be used as for example, a spotlight in an airport or AI aircrafts?
punkepanda
 
Posts: 234
Joined: Mon Nov 04, 2013 10:11 pm
Callsign: LostFlight
Version: 2.12
OS: Arch Linux

Re: ALS aircraft lights

Postby wlbragg » Sun Jul 31, 2016 11:22 pm

Wow, that is really cool! What a great addition to the arsenal.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7574
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: ALS aircraft lights

Postby radi » Mon Aug 01, 2016 2:41 am

Nice work Thorsten! I'd really love to know how you did this one.

glare lights up the clouds for miles and miles


So does a light now indeed illuminate its environment (as in ground, buildings, clouds, other aircrafts)?
OSM buildings for LOWI, EDDC
Custom scenery for VHXX YMML
Edit .stg via the FG Object Placement Tool
radi
 
Posts: 659
Joined: Mon Aug 25, 2008 5:24 pm
Location: YMML, EDDC

Re: ALS aircraft lights

Postby Thorsten » Mon Aug 01, 2016 6:36 am

Nice work Thorsten! I'd really love to know how you did this one.


Hint - think of a situation in which the clouds light up for a moment at a certain location. It virtually took no additional effort, all the technology was there.


So does a light now indeed illuminate its environment (as in ground, buildings, clouds, other aircrafts)?


I suppose we need to get this out of the way.

In real-time 3d rendering, there are no lights which illuminate anything really. There's no light source in the simulation from which rays are shot, interact with the environment and then hit something in the scene as in raytracing.

Try to put a Rembrandt light into an enclosed box - it's going to shine right through the box, because it really isn't a light. Try to put it into heavy fog, and it's neither going to illuminate the fog, not going to be attenuated - because it's not really a light.

All there is is a shader responsible for a triangle (which shader this is is driven by the effect), and that shader has access to the local surface properties plus whatever you tell it about the more global situation. From the perspective of the shader, our Sun is nothing but a uniform struct containing position and color information which shaders can access (or not). But what counts in the end is whatever color operations the shader decides to do.

Here's no localized light source in the scene at all - the shader is instructed to treat light like a liquid, it fills the low places and slowly creeps higher as the day progresses:

Image

Looking at such a picture, you can dispense with the fiction that there really are light sources in rendering.

It's all a bag of illusions. It's all different ways of handing global lighting information to the shader.

Rembrandt does this by placing artificial geometry into the scene and utilizing buffers. Which makes it deceptively easy for model designers to use it and pretend to actually put a light into the scene, because by and large it will be taken care of automagically. Of course this convenience for the designer costs the user in terms of framerate, because an additional pass over the scene is an additional pass, you touch every vertex twice.

But for many situations, there are other (much cheaper and better) ways to communicate global lighting and shadow information. Take a cockpit interior which is largely static in-sim lit by a ceiling light. You can compute this in Rembrandt every frame, and the result will be the same every frame (because it's static) and there won't ever be any shadows or reflected lightspots (because it's not a real light but just a quick trick).

You can also compute this situation offline with a raytracer and simply use the result in-sim (can take as long as it takes), and dump it to a table. You can have a high-order of reflections that way, objects shadow parts of the light, you can have the resulting distribution of the ambience,... and simply read the table in-sim - because it's a static problem. Then you use a lightmap and your cockpit lighting even casts the right shadows and reflections. You can even let the whole lit panel appear in the canopy glass (a raytracer does that easily) - at the simple expense of reading a texture, which is infinitely cheaper than a Rembrandt lighting pass.

So it's not a light you're seeing - it's a mixed bag of situation-specific tricks. Not as convenient for the aircraft designer, but usually more framerate friendly and sometimes even superior in visuals.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: ALS aircraft lights

Postby radi » Mon Aug 01, 2016 10:17 am

Now that hint really was a giveaway :D

Quite an elaborate answer, thanks Thorsten! I understand that FG is not meant to be raytracing, and that up until now (short of using Rembrandt, and with the exception of ALS landing lights), if I want something to be lit, I need to use a lightmap. However, for simplicity, let me still use "illuminates" and "light", even though there is no real light here (yet it looks a lot like it!) and it's all 'just' tricks.

What would happen if there was another model (airplane, building) just before the 172 in your first pic? Would that get illuminated as well, just as the ground is? Could this be applied to apron light poles, and if so, would they illuminate the ground and parked airplanes? In the first shuttle pic, if I'd replace the shuttle with a 747, would the 747 be lit by the floodlights?
OSM buildings for LOWI, EDDC
Custom scenery for VHXX YMML
Edit .stg via the FG Object Placement Tool
radi
 
Posts: 659
Joined: Mon Aug 25, 2008 5:24 pm
Location: YMML, EDDC

Re: ALS aircraft lights

Postby Thorsten » Mon Aug 01, 2016 10:43 am

Could this be applied to apron light poles, and if so, would they illuminate the ground and parked airplanes?


As I've tried to say, light is a property of the object being illuminated in rendering, not of an object illuminating. Always and unconditionally. You can point a Rembrandt light at a cloud at night and it won't show a thing - because the shader of the cloud doesn't know there is supposed to be light. The object being illuminated isn't prepared.

So if you apply anything to the light pole, it will never ever illuminate anything but the pole itself. If you want to illuminate an airplane, you need to apply light to the airplane. If you want to illuminate the ground, you need to apply light to the ground.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: ALS aircraft lights

Postby Thorsten » Mon Aug 01, 2016 12:26 pm

To answer the second part of the question:

It's a fairly general technique which can be applied to any objects (including clouds), but not to non-objects like haze or precipitation or objects not in our effect framework like particles.

Having said that, let's talk pricetag. The more things you want to illuminate, and the more light sources you want to simulate, the more expensive the technique is going to be (there'll be a break-even point for dozens or hundreds of lights beyond which deferred rendering will eventually be cheaper to do despite the required additional pass over the scene).

What framerate reduction would you accept for your position lights being able to illuminate a tree? Is this worth 5 fps slowdown (and how often will you be in that situation)? What would you consider an acceptable framerate loss for your landing light illuminating clouds properly? Is the shadow cast by your plane as you pass underneath a light worth losing 20 fps? Is having that shadow projected and blurred properly worth another 10 fps? What's the acceptable pricetag for the headlight of an AI car 500 m away to actually illuminate its surroundings?

It's not that these things could not be done - but we're quickly talking situations which you hardly ever get to experience in-sim (even support for lights in exterior views is something on the level of less than 5% of my sim-time - I usually don't watch landings in exterior view, because I have to look out of the window while I do it!) - and quickly growing pricetags.

So given that framerate is a rare commodity (and can be spent for much more prominent visuals, say the glow of city lights reflected on clouds) - what's the framerate loss you would be willing to trade to have what effect?

And what's the framerate loss you're willing to pay for designer convenience, i.e. for not simply using a lightmap in a static situation despite its clear superiority?
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: ALS aircraft lights

Postby punkepanda » Tue Aug 02, 2016 12:07 am

Thorsten wrote in Mon Aug 01, 2016 6:36 am:Here's no localized light source in the scene at all - the shader is instructed to treat light like a liquid, it fills the low places and slowly creeps higher as the day progresses

Supercool stuff.. What about a vulcano outbreak at night-time with lighting magma based on temperature and volume:)

So to put things really short; Any object could be a light source that triggers surrounding objects lightmap. But the object being illuminated need to be aware of any light sources that can trigger in realtime?

Practical speaking every aircraft need to have some lightmap listener code to it to be illuminated by a light pole and any light pole need to pass the parameters for the aircraft lightmap to listen to?

How much framerate loss are we really talking about if this is done in a optimal way? Lets say every object in an airport be aware of any light source.
I think this needs to be tested out in an working scenario.
punkepanda
 
Posts: 234
Joined: Mon Nov 04, 2013 10:11 pm
Callsign: LostFlight
Version: 2.12
OS: Arch Linux

Re: ALS aircraft lights

Postby Thorsten » Tue Aug 02, 2016 6:07 am

Practical speaking every aircraft need to have some lightmap listener code to it to be illuminated by a light pole and any light pole need to pass the parameters for the aircraft lightmap to listen to?


The salient point is that only the one light currently illuminating the aircraft needs to pass any parameters - for the rest it is enough to know that they're far away, and they don't even need to be handled 'per frame' (if a light is 3 km distant, you're unlikely to reach it in the next frame).

Lets say every object in an airport be aware of any light source.


Then it's an m*n problem wasting lots of effort illuminating static situations. If you want every object to be able to illuminate every other object, use Rembrandt, that's my best advice. My view is that you get 99.9 % of the visuals for 10% of the cost by making *your own* aircraft exchange light information with a limited class of objects.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Next

Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 1 guest