Project Rembrandt: Difference between revisions

Line 740: Line 740:
|}
|}
|}
|}
==== Performance and compatibility considerations ====
Every light on screen is equivalent for the GPU of redrawing the light volume with a shader, without z buffer culling. So each light comes with a cost, that is small taken individually but noticeable when a lot of them are visible. That cost also increase with the size of the light volume.
Beside that, it is wise to allow a model to work with the classical renderer that know nothing about lights and would render light volumes like other geometry. So a good practice is to complement each light animation with a select animation checking :
*if Rembrandt is enabled
*if the user selected quality match with the purpose of the light
*if the light should be on or off according to the other parameters of the simulation (position of the sun, position of switch, presence of power, ...)
A quality property is created to reflect the user preferences about quality vs performance concerning lights, and a proper slider is added to the shader dialog.
[[File:Fgfs-shaders-with-light.jpg|thumb|Light quality slider]]
The propery to use is :
/sim/rendering/shaders/lights
The quality slider sets its range from 0 (no lights) to 4 (all lights on). Simple airport lamp post appears at 1. Few bridge lamps at 2, all simple bridge lamp at 3 and more involved one at 4.
Example:
<syntaxhighlight lang="xml">
<animation>
  <type>light</type>
  <light-type>spot</light-type>
  <name>LightSource</name>
  <object-name>LightVolume</object-name>
  ...
</animation>
<animation>
  <type>select</type>
  <!-- Select the named animation -->
  <object-name>LightSource</object-name>
  <condition>
      <and>
        <!-- Rembrandt enabled ? -->
        <property>/sim/rendering/rembrandt/enabled</property>
        <!-- Quality ok ? -->
        <greater-than>
            <property>/sim/rendering/shaders/lights</property>
            <value>3.0</value>
        </greater-than>
        <!-- Simulation conditions ? -->
        <greater-than>
            <property>/sim/time/sun-angle-rad</property>
            <value>1.57</value>
        </greater-than>
      </and>
  </condition>
</animation>
</syntaxhighlight>


== TODO List ==
== TODO List ==
269

edits