Effects: Difference between revisions

Jump to navigation Jump to search
2,975 bytes added ,  2 September 2017
no edit summary
No edit summary
No edit summary
Line 55: Line 55:
   |script_version = 0.40  
   |script_version = 0.40  
   }}</ref>
   }}</ref>
An effect is a container for a series of techniques which are all the possible things you could do with some object.
The &lt;predicate&gt; section inside each effect determines which of the techniques we actually run. Typically the predicate section contains conditionals on a) rendering framework properties b) OpenGL extension support and c) quality level properties. The renderer searches the effects from lowest to highest technique number and uses the first one that fits the bill (which is why high quality levels precede low quality levels).
The rendering itself is specified as &lt;pass&gt; - each pass runs the renderer over the whole scene. We may sometimes make a quick first pass to fill the depth buffer or a stencil buffer, but usually we render with a single pass.
Techniques may not involve a shader at all, for instance 12 in terrain-default is a pure fixed pipeline fallback technique, but all the rendering you're interested in use a shader, which means they have a &lt;program&gt; section which determines what actual code is supposed to run.
If you run a shader, that needs parameters specified as &lt;uniform&gt;, and textures which need to be assigned to a texture unit _and_ be declared as a uniform sampler.
In addition, each technique contains a host of parameter configuring the fixed pipeline elements, like alpha tests before the fragment stage, or depth buffer writing/reading, alpha blending,... you can ignore them on the first go.
So if you want to look at which shader code is executed when you call the water effect at a certain quality level, you need to work your way through the predicate sections of the techniques from lowest to highest till you find the one that matches, and then look into the program section of that technique.
Now, to make matters more complicated, all the parameters and textures that are assigned to uniforms and texture units in the techniques need to be declared and linked to properties were applicable in the &lt;parameters&gt; section heading each effect declaration. So a texture you want to use has to appear three times - in the parameters section heading the effect, inside the technique assigned to a texture unit and assigned to a uniform sampler.
Now, inheritance moves all the declared parameters and techniques from one effect to the one inheriting. In the case of water, that means the technique is actually _not_ inherited because terrain-default.eff doesn't contain a technique 1 at all, but the general &lt;parameters&gt; section is inherited. So you don't need to declare the additions to &lt;parameters&gt; again, but you do need to make the changes to the &lt;programs&gt; and the &lt;uniform&gt; sections.<ref>{{cite web
  |url    =  https://forum.flightgear.org/viewtopic.php?p=220152#p220152
  |title  =  <nowiki> Re: ALS landing lights </nowiki>
  |author =  <nowiki> Thorsten </nowiki>
  |date  =  Oct 8th, 2014
  |added  =  Oct 8th, 2014
  |script_version = 0.40
  }}</ref>




Navigation menu