Board index FlightGear Development Aircraft

Emission material animation also changes ambient color

Questions and discussion about creating aircraft. Flight dynamics, 3d models, cockpits, systems, animation, textures.

Emission material animation also changes ambient color

Postby TheEagle » Sat Sep 03, 2022 7:01 pm

I have the following in the main XML file of my PC-6 model:
Code: Select all
   <animation>
      <type>material</type>
      <object-name>FuelValveHandle</object-name>
      <object-name>Panel</object-name>
      <object-name>PanelFloor</object-name>
      <object-name>ElevatorTrimControlsMount</object-name>
      <object-name>ElevatorTrimInterruptSwitch</object-name>
      <object-name>ElevatorTrimInterruptSwitchMount</object-name>
      <object-name>ElevatorTrimInterruptSwitchGuard</object-name>
      <object-name>ElevatorTrimInterruptSwitchGuardMount</object-name>
      <object-name>ElevatorTrimSwitch</object-name>
      <object-name>ElevatorTrimSwitchMount</object-name>
      <object-name>BarPanel</object-name>
      <object-name>ParkingBrakeHandle</object-name>
      <object-name>RegistrationPlatePanelLeft</object-name>
      <object-name>RegistrationPlatePanelRight</object-name>
      <object-name>ControlStick</object-name>
      <object-name>ControlStickTriggerButton</object-name>
      <object-name>ControlStickTrimSwitch</object-name>
      <object-name>Left Electric Switches Panel</object-name>
      <object-name>Right Electric Switches Panel</object-name>
      <object-name>EngineControlsMount</object-name>
      <object-name>EngineControlsConditionLever</object-name>
      <object-name>EngineControlsPropellerPitchLever</object-name>
      <object-name>EngineControlsThrottleLever</object-name>
      <object-name>Left Circuit breakers Panel</object-name>
      <object-name>Right Circuit breakers Panel</object-name>
      <object-name>FlapsLever</object-name>
      <object-name>FlapsLeverMount</object-name>
      <object-name>Placards</object-name>
      <emission>
         <red>0.2</red>
         <green>0.2</green>
         <blue>0.2</blue>
         <factor-prop>controls/lighting/light_cabin</factor-prop>
      </emission>
   </animation>

which is supposed to mimick an overhead panel light's shine on the panel parts. But instead of making the panel "glow" a bit white in the dark, this gives the panel a dark red color with <factor-prop> set to false and a white emission that appears a bit red (due to the diffuse color being red) with <factor-prop> set to true. if I comment out the <emission> part the red color disappears, but of course I don't get any emission anymore, either.

So, what could be causing this ? I'm not applying any other material animations to the panel parts (searching for "Panel" in the XML file only gave one match … in the above emission animation) nor any effects, also the object has no texture assigned and all material colors are set to grey in the AC file:
Code: Select all
MATERIAL "PanelMaterial" rgb 0.523 0.523 0.523  amb 0.523 0.523 0.523  emis 0.000 0.000 0.000  spec 1.000 1.000 1.000  shi 64 trans 0.000


EDIT: Adding
Code: Select all
      <ambient>
         <red>0.523</red>
         <green>0.523</green>
         <blue>0.523</blue>
      </ambient>

to the above animation code fixes the colors, but it's a hack, and I'd have to keep the values in sync whenever I change the material color in Blender - there must be a better solution ???
Last edited by TheEagle on Sun Sep 04, 2022 11:37 am, edited 1 time in total.
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: Emission material animation also changes diffuse / ambie

Postby Thorsten » Sun Sep 04, 2022 8:30 am

I guess it depends a bit on which shader processes the thing in the end - material animations are pre-effect things, and the better solution is simply to set the shader effect to produce the visuals you want - a lightmap is the modern way to show something shine down on something else, also the interior shaders allow you to use things like irradiance maps to modulate indirect light in certain ways.

So it is possible that there's a mismatch between what the animation wants to do and what the effect rendering the surface expects to be done.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Emission material animation also changes diffuse / ambie

Postby TheEagle » Sun Sep 04, 2022 11:07 am

I know lightmaps (or compositor lights on next / trunk, with the drawback of missing shadows) are the better choice, but I didn't start the PC-6, I'm only improving it, and I inherited the emission animation from the original version. The thing is, it worked without issues before I started working on it - but all I did was changing some object names and some material colors - I did not apply any effects to the objects concerned ! :(
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: Emission material animation also changes ambient color

Postby TheEagle » Sun Sep 04, 2022 11:47 am

For testing purposes, i added a cube to the aircraft model in Blender, assigned no material (so it gets the DefaultWhite material), exported to AC file, then added <object-name>Cube</object-name> to the material emission animation. Those are ALL changes I did !

And guess what I got ? A red cube ! On the top face it is almost white with a little red tint, but on the sides it has a dark red, so it definitely is the ambient color that gets changed. why I have no idea …
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: Emission material animation also changes ambient color

Postby TheEagle » Sun Sep 04, 2022 12:32 pm

Unchecking "Amb same as Diff" in the Blender AC3D export dialog partially solves the problem, in that the panel now has a white ambient color instead of red, but everything else got white ambient color too …
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: Emission material animation also changes ambient color

Postby TheEagle » Sun Sep 04, 2022 1:37 pm

So, I found the bug - it is indeed within FlightGear (if it's not me being too dumb to use it). I have un-hidden all objects in Blender and reexported. Now I have this code in my XML file:
Code: Select all
   <animation>
      <type>material</type>
      <object-name>FuelValveHandle</object-name>
      <object-name>Panel</object-name>
      <object-name>EngineControlsConditionLever</object-name>
      <object-name>EngineControlsPropellerPitchLever</object-name>
      <object-name>EngineControlsThrottleLever</object-name>
      <emission>
         <red>0.2</red>
         <green>0.2</green>
         <blue>0.2</blue>
         <factor-prop>controls/lighting/light_cabin</factor-prop>
      </emission>
   </animation>

The FuelValveHandle has a red material, the Panel is light grey, the condition lever bright red, the propeller pitch lever bright blue and the throttle lever black. With the above code, all objects listed turn red. If I comment out the FuelValveHandle, everything left turns light grey. If I additionally comment out the Panel, everything turns bright red again. If I additionally comment out the condition lever, the prop pitch and throttle levers turn blue … I guess you can see the pattern ?

TL;DR; It looks like for material animations, the ambient color is inherited from the first object listed, which is … wrong. Am i supposed to make one emission animation for EACH and EVERY object out of 30 ? What a mess.
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: Emission material animation also changes ambient color

Postby TheEagle » Sun Sep 04, 2022 4:00 pm

I gave up on the emission animation and put a Compositor light instead - looks much nicer ! :) Especially since someone seems to have implemented normals checking - so the light no longer illuminates two opposing sides of the same object ! I have just one problem - my <range-m> is not respected. The light (placed about 2 meters above the wheels) illuminates also the ground, not only the cockpit, no matter if I put a <range-m> value of 0.1 or 10. Any suggestions ? I want the light cone to be really cut-off at 1.5 meters.
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


Return to Aircraft

Who is online

Users browsing this forum: No registered users and 13 guests