Board index FlightGear Development Effects and shaders

Interpolation on lightmap factor

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

Interpolation on lightmap factor

Postby bigstones » Fri May 02, 2014 3:03 pm

Hello, I'm trying to add lightmaps to some building models. The problem is that, I've read, conditionals are not supported in effects and indeed it's not working here. So I went for the factor route, which works but needs some interpolation tuning.

If that's not possible either, are there properties in the tree that I can use for this purpose? Also, I see that sun-angle-rad is updated quite often, isn't binding an effect to that property going to be heavy as the range animation?

Here's my XML file:
Code: Select all
<?xml version="1.0"?>
<PropertyList>
  <path>LIPY_terminalOld.ac</path>

  <effect>
    <object-name>facciate</object-name>
    <object-name>dettagli</object-name>
    <inherits-from>Effects/lightmap</inherits-from>
    <parameters>
      <texture n="1">
        <image>TEXTURE LIPY 2_L.png</image>
      </texture>
<!--
      <condition>
        <greater-than>
          <property>/sim/time/sun-angle-rad</property>
          <value>1.48</value>
        </greater-than>
      </condition>
-->
      <factor>
        <use>/sim/time/sun-angle-rad</use>
        <interpolation>
          <entry>
            <ind> 0.0</ind>
            <dep> 0.0</dep>
          </entry>
          <entry>
            <ind> 1.48</ind>
            <dep> 0.0</dep>
          </entry>
          <entry>
            <ind> 1.66</ind>
            <dep> 1.0</dep>
          </entry>
          <entry>
            <ind> 3.14</ind>
            <dep> 1.0</dep>
          </entry>
        </interpolation>
      </factor>
    </parameters>
  </effect>

</PropertyList>



Thanks for any help.
bigstones
 
Posts: 95
Joined: Sat Apr 05, 2014 11:09 pm
Location: Italy
Callsign: I-NOOB
OS: Debian testing

Re: Interpolation on lightmap factor

Postby Thorsten » Fri May 02, 2014 3:23 pm

Also, I see that sun-angle-rad is updated quite often, isn't binding an effect to that property going to be heavy as the range animation?


No, <factor> is directly passed to the shader as a uniform, which means it's evaluated on the GPU per frame whether it changes or not, and uniforms are generally cheap.

The range animation is not passed to a shader effect, it is evaluated on the CPU and decided before an object enters the rendering pipeline, which makes it more expensive.
Thorsten
 
Posts: 10638
Joined: Mon Nov 02, 2009 8:33 am

Re: Interpolation on lightmap factor

Postby bigstones » Fri May 02, 2014 3:42 pm

Thorsten wrote in Fri May 02, 2014 3:23 pm:No, <factor> is directly passed to the shader as a uniform, which means it's evaluated on the GPU per frame whether it changes or not, and uniforms are generally cheap.

Great. But so I guess I have to add some custom 'passMeAsAFactorToLightmapEffectsForBuildings' property to the tree, updated by a Nasal interpolator, to pass it to <factor>. I guess also this is why I couldn't find yet an example of a building that has lightmaps.
bigstones
 
Posts: 95
Joined: Sat Apr 05, 2014 11:09 pm
Location: Italy
Callsign: I-NOOB
OS: Debian testing

Re: Interpolation on lightmap factor

Postby Thorsten » Fri May 02, 2014 5:08 pm

Shouldn't be a Nasal interpolator, I think a property rule would be the tool of choice. But yeah, it seems like, I've just checked that both the building and the urban shaders just use light intensity as a proxy and crank up lights as the scene light goes down. I guess that could have been done for the lightmap shader as well, but people wanted it more flexible and configurable.

Well - note that the lightmap is considered obsolete, and there's no support for it in either ALS or Rembrandt - you're encouraged to use the lightmap option of the model ubershader (model-combined.eff) instead. Although that also calls for a factor.

So, bottomline, I think we need to provide a property rule for such purposes to have a property which can be directly used as lightmap factor if you don't want to do anything fancy.
Thorsten
 
Posts: 10638
Joined: Mon Nov 02, 2009 8:33 am

Re: Interpolation on lightmap factor

Postby bigstones » Fri May 02, 2014 7:45 pm

Thorsten wrote in Fri May 02, 2014 5:08 pm:Well - note that the lightmap is considered obsolete, and there's no support for it in either ALS or Rembrandt - you're encouraged to use the lightmap option of the model ubershader (model-combined.eff) instead. Although that also calls for a factor.

I just tried the newer effect, I need the lightmap to repeat (it's the sides of a glassmade terminal) so I set <wrap-t> and <wrap-s> to 'repeat'. But it changes nothing (actually just stays with the edge pixels extended vertically and horizontally). Is there a 'tile' option?

If that's not the case, should I stick to the older effect, or better tile the panels in a new texture to be used without repeat?
bigstones
 
Posts: 95
Joined: Sat Apr 05, 2014 11:09 pm
Location: Italy
Callsign: I-NOOB
OS: Debian testing

Re: Interpolation on lightmap factor

Postby Thorsten » Sat May 03, 2014 5:25 am

I just tried the newer effect, I need the lightmap to repeat (it's the sides of a glassmade terminal) so I set <wrap-t> and <wrap-s> to 'repeat'. But it changes nothing (actually just stays with the edge pixels extended vertically and horizontally).


How exactly does your xml of this look like? I see that the defaults in the effect are indeed set to clamp, but you should be able to override that when you declare the effect.
Thorsten
 
Posts: 10638
Joined: Mon Nov 02, 2009 8:33 am

Re: Interpolation on lightmap factor

Postby bigstones » Sat May 03, 2014 9:48 am

Thorsten wrote in Sat May 03, 2014 5:25 am:How exactly does your xml of this look like? I see that the defaults in the effect are indeed set to clamp, but you should be able to override that when you declare the effect.

Here it is:
Code: Select all
<?xml version="1.0"?>
<PropertyList>
   <path>LIPY_terminalSW.ac</path>
   
   <effect>
    <object-name>vetrate</object-name>
    <inherits-from>Effects/model-combined-deferred</inherits-from>
    <parameters>
      <lightmap-enabled type="int">1</lightmap-enabled>
      <texture n="3">
        <image>VETRATA TERMINAL_L.png</image>
      </texture>
      <lightmap-factor type="float" n="0"><use>/sim/time/sun-angle-rad</use></lightmap-factor>
      <wrap-s>repeat</wrap-s>
      <wrap-t>repeat</wrap-t>
      <filter>linear-mipmap-linear</filter>
      <internal-format>normalized</internal-format>
    </parameters>
  </effect>
   
  ...

</PropertyList>
bigstones
 
Posts: 95
Joined: Sat Apr 05, 2014 11:09 pm
Location: Italy
Callsign: I-NOOB
OS: Debian testing

Re: Interpolation on lightmap factor

Postby Thorsten » Sat May 03, 2014 9:57 am

<wrap-s> and <wrap-t> need to go inside the texture declaration to do anything, so does <filter> and <internal-format>. They're not independent parameters, they're sub-paameters associated with texture 3.
Thorsten
 
Posts: 10638
Joined: Mon Nov 02, 2009 8:33 am

Re: Interpolation on lightmap factor

Postby bigstones » Sat May 03, 2014 10:12 am

Oops, I didn't read correctly the readme. Thank you again.
Last edited by Gijs on Sat May 03, 2014 2:15 pm, edited 1 time in total.
Reason: No useless quoting please
bigstones
 
Posts: 95
Joined: Sat Apr 05, 2014 11:09 pm
Location: Italy
Callsign: I-NOOB
OS: Debian testing


Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 1 guest