Board index FlightGear Development Scenery

Getting the distance between the object and the viewer  Topic is solved

Questions and discussion about enhancing and populating the FlightGear world.

Getting the distance between the object and the viewer

Postby TheEagle » Sat Jun 05, 2021 7:52 pm

I am making some custom runway lights. They are rather small (about 16 centimeters in Blender), and they disappear when I go way from them more than 1700 - 1800 feet. Simple fix would be to make them much bigger in Blender, but then, they would look weird in the scenery. My idea was to scale them up using the model's .xml file with a scale animation based on the distance between the object an the viewer - but I have no idea on how to get that distance. Is there a property somewhere in FG's property tree, or can someone tell me how to get the coordinates of the object and the viewer and somehow calculate the distance in feet / meters based on that ?
EDIT: I looked at the Cessna 172p's strobe light's xml file and stumbled upon animation type dist-scale. It looks like that's just what what I need, but - I'm confused about what it's properties do - the docs don't provide any detailed explanation for them - can anyone help me on this, please ?
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Getting the distance between the object and the viewer

Postby Johan G » Sun Jun 06, 2021 6:12 am

It seems to be set up using an <interpolation> table, and my best guess would be that <dep> and <ind> (probably dependent and independent with respect to the scale) are the distance and scale at that distance.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Getting the distance between the object and the viewer

Postby TheEagle » Sun Jun 06, 2021 12:05 pm

Okay, I now got as far as being able to scale the lamps up based on the distance - but now, they simply disappear already at 550 feet distance ?! :?
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Getting the distance between the object and the viewer

Postby benih » Sun Jun 06, 2021 1:27 pm

Hard to answer without actual code
User avatar
benih
 
Posts: 1689
Joined: Tue Aug 15, 2017 10:34 am
Callsign: D-EBHX
Version: next
OS: Debian Linux 64bit

Re: Getting the distance between the object and the viewer

Postby Necolatis » Sun Jun 06, 2021 6:17 pm

IND is in meter, DEP is how much it shoudl scale that distance. You can put as many pair you want.
"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: Getting the distance between the object and the viewer

Postby TheEagle » Sun Jun 06, 2021 7:25 pm

Necolatis wrote in Sun Jun 06, 2021 6:17 pm:IND is in meter, DEP is how much it shoudl scale that distance. You can put as many pair you want.

Thanks - that was just the information I was searching for - is there any wiki on this ? And do you know what IND and DEP are the abbreviations of ?
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Getting the distance between the object and the viewer

Postby benih » Mon Jun 07, 2021 6:41 am

IND=Independend, and DEP=Dependent.
The scaling is generic, so the names are too, they are not directly related to the naming of you usecase.
Basicly: IND=the input value (moves independently as viewed from the scaling definition); DEP=output (depending on the input)

It could be the case, that you are just clipping the lower band.
You should define a scaling for the DEP=0 start, so the system knows how big it should be close up.
User avatar
benih
 
Posts: 1689
Joined: Tue Aug 15, 2017 10:34 am
Callsign: D-EBHX
Version: next
OS: Debian Linux 64bit

Re: Getting the distance between the object and the viewer

Postby Thorsten » Mon Jun 07, 2021 6:47 am

I am making some custom runway lights.


Then a scale animation with distance almost certainly won't do what you need.

Lights are really complicated, because their brightness in the scene is governed by two regimes - if they're larger than a pixel, the radius of the disc gives you an indication of the brightness, but if they're just a single pixel, then the transparency of that pixel is the parameter to change for brightness.

Furthermore, the apparent brightness depends on the light in the rest of the scene - a 100 W bulb carries quite some distance in a moonless night, but isn't particularly visible in bright daylight.

None of that you can really implement with any kind of model/animation combination, at best you can make approximately sure your light is always larger than a single pixel (though that depends on screen resolution just as well) and isn't rasterized away - but for even a halfway plausible light in the scene you need GLSL code to do the computations (we have the procedural light shader for just that purpose).
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Getting the distance between the object and the viewer

Postby Johan G » Mon Jun 07, 2021 9:41 am

Necolatis wrote in Sun Jun 06, 2021 6:17 pm:IND is in meter, DEP is how much it shoudl scale that distance. You can put as many pair you want.

TheEagle wrote in Sun Jun 06, 2021 7:25 pm:[...] that was just the information I was searching for - is there any wiki on this ?

There is now (diff). :)
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Getting the distance between the object and the viewer

Postby TheEagle » Mon Jun 07, 2021 11:03 am

Thorsten wrote in Mon Jun 07, 2021 6:47 am:Furthermore, the apparent brightness depends on the light in the rest of the scene - a 100 W bulb carries quite some distance in a moonless night, but isn't particularly visible in bright daylight.

My testing has been done i complete darkness - the only thing I see is the lights (when I see them :roll: )
Thorsten wrote in Mon Jun 07, 2021 6:47 am:None of that you can really implement with any kind of model/animation combination, at best you can make approximately sure your light is always larger than a single pixel (though that depends on screen resolution just as well) and isn't rasterized away

well, that was just what I was trying to do with the dist-scale - the lights were at least 5 pixels big from 550 feet, but disappeared all the same when I moved further away :? :?:
Thorsten wrote in Mon Jun 07, 2021 6:47 am:but for even a halfway plausible light in the scene you need GLSL code to do the computations (we have the procedural light shader for just that purpose).

Yeah, I found that procedural light effect too, but I just don't know how to use it - is there maybe a HowTo I missed, or can you explain or provide an example ?

I also thought about using simple point sprites - but I have no idea how to do so, and could not find any docs on this :roll:
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Getting the distance between the object and the viewer

Postby Thorsten » Mon Jun 07, 2021 4:12 pm

Yeah, I found that procedural light effect too, but I just don't know how to use it - is there maybe a HowTo I missed, or can you explain or provide an example ?


10 seconds with google 'flightgear wiki als procedural light' gives you this

https://wiki.flightgear.org/ALS_technic ... ral_lights
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Getting the distance between the object and the viewer

Postby TheEagle » Mon Jun 07, 2021 5:31 pm

Thorsten wrote in Mon Jun 07, 2021 4:12 pm:10 seconds with google 'flightgear wiki als procedural light' gives you this

https://wiki.flightgear.org/ALS_technic ... ral_lights


Yeah, I found that in the meantime too, I just didn't think of posting that :roll: , sorry :(
But I could find nothing about how to add a point sprite light to a model - is that possible at all ?
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Re: Getting the distance between the object and the viewer

Postby Thorsten » Mon Jun 07, 2021 6:24 pm

No, you can't add a point sprite to a model - which is why the procedural light exists - to provide something equivalent which you can add to a model.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Getting the distance between the object and the viewer

Postby richter » Sun Oct 17, 2021 1:15 pm

TheEagle wrote in Sun Jun 06, 2021 12:05 pm:Okay, I now got as far as being able to scale the lamps up based on the distance - but now, they simply disappear already at 550 feet distance ?! :?


I am having the exact same problem. dist-scale animated objects disappear beyond about 200 meters.
Aircraft: Britten-Norman BN-2 Islander
Airports: RJTT
richter
 
Posts: 119
Joined: Tue Jan 27, 2009 5:58 pm
Location: Tokyo
Version: 2
OS: Slackware Linux 12.2

Re: Getting the distance between the object and the viewer

Postby TheEagle » Sun Oct 17, 2021 2:11 pm

Well, do you have a range animation already ? I think I forgot it that time…
Also, check your LOD settings - small scenery objects might be considered to be detailed LOD, and if you have set that too low, they will simply disappear.
What kin of object do you mean ? A light like in my case ?
Cessna 210 (Wiki)
My other aircraft: my wiki profile !
Other: FGTools (GitHub)
World tour: View on SkyVector
Please consider donating $1 / €1 to help me finance a new camera !
User avatar
TheEagle
 
Posts: 3411
Joined: Sat May 01, 2021 3:27 pm
Location: France
Pronouns: You, he
Callsign: F-EAGLE
IRC name: none
Version: Git next
OS: Ubuntu Studio 22.04

Next

Return to Scenery

Who is online

Users browsing this forum: No registered users and 8 guests