Board index FlightGear Development Effects and shaders

Disabeling an effect on a condition ?

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

Disabeling an effect on a condition ?

Postby StuartC » Fri Sep 22, 2017 10:24 am

Playing with fuselage effects and I would like to be able to disble a reflection effect while Rembrandt is enabled, because it becomes too shiny and almost mirror like.

I have tried the following with the ,<effect> tags in the model XML :-

<condition>

<property>sim/rendering/rembrandt/enabled</property>
<value>false</value>

</condition>

to turn it on when Rembrandt is not enabled, and I have also tried the inverse :-

<condition>
<not>
<property>sim/rendering/rembrandt/enabled</property>
<value>true</value>
</not
</condition>


nether have an efeect or the effect. It stays active regardless.

Any other way I can achieve this?
StuartC
 
Posts: 2513
Joined: Fri Jun 18, 2010 8:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2.12
OS: W7 64 bit

Re: Disabeling an effect on a condition ?

Postby Thorsten » Fri Sep 22, 2017 10:32 am

Conditions do not work in effects, they use predicates instead and these should not be altered by users.

You ought to be able to condition on the property rule (or whatever other technology you use) that sets the reflection strength property.

(If you're using model-combined-deferred.eff, it should actually not be necessary, so something is odd here).
Thorsten
 
Posts: 9368
Joined: Mon Nov 02, 2009 8:33 am

Re: Disabeling an effect on a condition ?

Postby StuartC » Fri Sep 22, 2017 11:18 am

I have this in the set file which sets the strength of the reflection:-

<rendering>
<refl_correction type="string">-0.2</refl_correction>
</rendering>
StuartC
 
Posts: 2513
Joined: Fri Jun 18, 2010 8:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2.12
OS: W7 64 bit

Re: Disabeling an effect on a condition ?

Postby Thorsten » Fri Sep 22, 2017 11:46 am

I'd be surprised if that does anything... effects don't work like that. This needs to go into the derived effect, not the *-set.xml.

How are you assigning the effect? I'd like to understand why this doesn't work properly for Rembrandt, because the reflection code is practically identical among all three rendering frameworks, so different visuals should just not happen.
Thorsten
 
Posts: 9368
Joined: Mon Nov 02, 2009 8:33 am

Re: Disabeling an effect on a condition ?

Postby StuartC » Fri Sep 22, 2017 12:12 pm

in the model file I have something like this ( including the non functional condition )

Code: Select all
<effect>
      <inherits-from>Aircraft/myaircraft/Models/Effects/reflect-uber</inherits-from>
       <condition>
   
      <property>sim/rendering/rembrandt/enabled</property>
     <value>false</value>
   
    </condition>
      <object-name>fuselage</object-name>
      <object-name>frontdoor_right</object-name>
      <object-name>frontdoor_left</object-name>
      <object-name>backdoor_right</object-name>
      <object-name>backdoor_left</object-name>
      <object-name>wire_cutter</object-name>
      <object-name>skid</object-name>
      <object-name>skid_floats</object-name>
      <object-name>sandfilter</object-name>
      <object-name>reardoor_right</object-name>
      <object-name>reardoor_left</object-name>
      <object-name>reardoor_wind_right</object-name>
      <object-name>reardoor_wind_left</object-name>
      <!--<object-name>radom</object-name>
      <object-name>nose</object-name>-->
      <object-name>Plane.009</object-name>
      <object-name>Plane.010</object-name>
      <object-name>nacaintake</object-name>
</effect>


The code in the set file is affecting the reflection level on ALS, but has no effect on Rembrandt where the effect mas an almost mirror like quality.

The code from the effect file looks like this:-

Code: Select all
<PropertyList>
  <name>reflect-uber1</name>
  <inherits-from>Effects/model-combined-deferred</inherits-from>
  <parameters>
    <normalmap-enabled type="int">1</normalmap-enabled>
    <normalmap-dds type="int">0</normalmap-dds>
    <texture n="2">
      <image>Aircraft/myaircraft/Models/Effects/bumpmap.png</image>
      <filter>linear-mipmap-linear</filter>
      <wrap-s>repeat</wrap-s>
      <wrap-t>repeat</wrap-t>
      <internal-format>normalized</internal-format>
    </texture>
    <!--lightmap-->
    <lightmap-enabled type="int">1</lightmap-enabled>
    <lightmap-multi type="int">1</lightmap-multi>
    <lightmap-factor type="float" n="0"><use>/systems/electrical/outputs/beacon-itensity</use></lightmap-factor>
    <lightmap-color type="vec3d" n="0"> 1.0 0.0 0.0 </lightmap-color>
    <lightmap-factor type="float" n="1"><use>/systems/electrical/outputs/taxi-light-itensity</use></lightmap-factor>
    <lightmap-color type="vec3d" n="1"> 1.0 1.0 1.0 </lightmap-color>
    <lightmap-factor type="float" n="2"><use>/systems/electrical/outputs/landing-light-intensity</use></lightmap-factor>
    <lightmap-color type="vec3d" n="2">1.0 1.0 1.0 </lightmap-color>
    <lightmap-factor type="float" n="3">0.0</lightmap-factor>
    <lightmap-color type="vec3d" n="3">1.0 0.0 0.0 </lightmap-color>
    <texture n="3">
      <image>Aircraft/myaircraft/Models/Effects/Lightmaps.png</image>
      <filter>linear-mipmap-linear</filter>
      <wrap-s>clamp</wrap-s>
      <wrap-t>clamp</wrap-t>
      <internal-format>normalized</internal-format>
    </texture>

    <reflection-enabled type="int">1</reflection-enabled>
    <reflect-map-enabled type="int">1</reflect-map-enabled>
    <reflection-correction type="float"><use>/sim/rendering/refl_correction</use></reflection-correction>
    <reflection-dynamic type="int">1</reflection-dynamic>
    <texture n="4">
      <image>Aircraft/myaircraft/Models/Effects/greymap.png</image>
      <filter>linear-mipmap-linear</filter>
      <wrap-s>clamp</wrap-s>
      <wrap-t>clamp</wrap-t>
      <internal-format>normalized</internal-format>
    </texture>
    <texture n="5">
      <type>cubemap</type>
      <images>
        <positive-x>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_px.png</positive-x>
        <negative-x>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_nx.png</negative-x>
        <positive-y>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_py.png</positive-y>
        <negative-y>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_ny.png</negative-y>
        <positive-z>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_pz.png</positive-z>
        <negative-z>Aircraft/Generic/Effects/CubeMaps/real.blue-sky/fair-sky_nz.png</negative-z>
      </images>
    </texture>
    <reflection-fresnel type="float">0.01</reflection-fresnel>
    <reflection-rainbow type="float">0.2</reflection-rainbow>
    <reflection-noise type="float">0.01</reflection-noise>
    <ambient-correction type="float">0.0</ambient-correction>
    <dirt-enabled type="int">0</dirt-enabled>
    <dirt-color type="vec3d">1.0 1.0 1.0</dirt-color>
    <dirt-factor type="float">0.5</dirt-factor>
  </parameters>

<!-- ####################
### NORMALMAP INCLUDE ###
######################### -->

  <generate>
    <tangent type="int">6</tangent>
    <binormal type="int">7</binormal>
  </generate>

  <technique n="4">
    <pass>
      <program>
        <attribute>
          <name>tangent</name>
          <index>6</index>
        </attribute>
        <attribute>
          <name>binormal</name>
          <index>7</index>
        </attribute>
      </program>
    </pass>
  </technique>

  <technique n="7">
    <pass>
      <program>
        <attribute>
          <name>tangent</name>
          <index>6</index>
        </attribute>
        <attribute>
          <name>binormal</name>
          <index>7</index>
        </attribute>
      </program>
    </pass>
  </technique>

  <technique n="9">
    <pass>
    <program>
      <attribute>
      <name>tangent</name>
      <index>6</index>
      </attribute>
      <attribute>
      <name>binormal</name>
      <index>7</index>
      </attribute>
    </program>
    </pass>
  </technique>

<!-- ########################
### END NORMALMAP INCLUDE ###
############################# -->
</PropertyList>
Last edited by Johan G on Sun Oct 08, 2017 6:03 pm, edited 1 time in total.
Reason: Added [code] tags
StuartC
 
Posts: 2513
Joined: Fri Jun 18, 2010 8:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2.12
OS: W7 64 bit

Re: Disabeling an effect on a condition ?

Postby Thorsten » Fri Sep 22, 2017 2:26 pm

It's this line in the derived effect where you connect the effect to the property:

Code: Select all
<reflection-correction type="float"><use>/sim/rendering/refl_correction</use></reflection-correction>


(note that this should certainly not be assigned a type 'string' in the set file - it should be a float if it goes to the renderer).

You say this has no effect on Rembrandt at all? This is very weird, I'm just comparing the relevant fragment shader code side by side, and the way the reflection correction is treated is the same. Also, the relevant effect sections defining the shader parameters are all there.

What does the Classic renderer do then? Or what happens if you use the above line to assign a constant value?
Thorsten
 
Posts: 9368
Joined: Mon Nov 02, 2009 8:33 am

Re: Disabeling an effect on a condition ?

Postby StuartC » Fri Sep 22, 2017 4:02 pm

comparison using the same settings on the 3 render engines:-
Classic rendering:-
Image

ALS rendering:-
Image


Rembrandt:-
Image

All using the same weather + time of day and approx. camera position
StuartC
 
Posts: 2513
Joined: Fri Jun 18, 2010 8:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2.12
OS: W7 64 bit

Re: Disabeling an effect on a condition ?

Postby Thorsten » Fri Sep 22, 2017 4:42 pm

Hm, I had expected something more dramatic from the description.... by and large the reflection looks okay, it just seems to be the color is different.

Heiko has prodded me to change the way color in the reflection is merged in ALS, but actually Classic hasn't been touched, so it seems just Rembrandt is just doing something different here.

So - can you confirm that changing reflection strength correction does nothing at all for Rembrandt? Otherwise the easiest solution is probably to just set the property to a different value when Rembrandt is on.

(Or to simply accept what the renderer does - micro-managing this model side hardly ever works when the lighting conditions change - the result looks acceptable to me in all three cases)
Thorsten
 
Posts: 9368
Joined: Mon Nov 02, 2009 8:33 am

Re: Disabeling an effect on a condition ?

Postby StuartC » Fri Sep 22, 2017 5:58 pm

Changed the rendering offset from the set file to -0.9, and the shine is unchanged just like it is above on rembrandt
It looks like the guy who washes the chopper has went a bit overboard with the polish. The top 2 screen shots are the correct colour of the paint, nut super shiny burgundy and polished gold leaf.

But, hold on. I have found out the cause.
If the livery has code in it like:-
<diffuse>
<red-prop>diffuse/red</red-prop>
<green-prop>diffuse/green</green-prop>
<blue-prop>diffuse/blue</blue-prop>
</diffuse>

<specular>
<red-prop>specular/red</red-prop>
<green-prop>specular/green</green-prop>
<blue-prop>specular/blue</blue-prop>
</specular>

That's whats screwing it over on Rembrandt. Removing that code I gert a reflection level that's somewhere between the classic + ALS levels of reflection.

Moral of the story is, check the livery code..............
StuartC
 
Posts: 2513
Joined: Fri Jun 18, 2010 8:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2.12
OS: W7 64 bit

Re: Disabeling an effect on a condition ?

Postby Thorsten » Sat Sep 23, 2017 5:16 am

Moral of the story is, check the livery code..............


Good catch - I never even knew you could do this kind of hack in the livery code!

Two final comments:

1) I believe the terminology is wrong - the color difference seen has nothing to do with the reflection level (the reflection level is the degree to which you see the environment map)

If I give Vostok a high reflectivity, it looks like that

Image

you see no color of the object itself, just the environment map. So the real cause here was a shift in surface color, the reflection is the same everywhere (which is why the reflectivity did not influence the issue).

And, needless to say - the hack is physically wrong and pretty bad (and to some degree ALS is written to just ignore these things, which is probably why this didn't take).

2) If you pass a parameter via <use> from the property tree to an effect, you get the ability to change it runtime. So you should only do that if you need to change it runtime - advising the renderer to use a constant property determined in the set file is plain confusing - especially when the property referenced is not even in the aircraft's own property tree structure but within FGs global rendering parameters.

So if you want it a constant, just set it to a constant in the derived effect.
Thorsten
 
Posts: 9368
Joined: Mon Nov 02, 2009 8:33 am


Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 1 guest