Jump to: navigation, search

Howto:Shader programming in FlightGear

798 bytes added, 18:29, 13 October 2014
add property tree verbiage
They show up in the [[Property Tree ]] under sim/rendering/als-secondary-lights and can be activated or manipulated by normal [[Nasal|Nasal]] calls or [[Xml|XML]].
=== Property Tree ===
The [[Property Tree]] is like the CPU of the [[FlightGear]] program at a user level. It's a go-between that allows the user to see and influence many aspects at the heart of the program in ALMOST real time. More of the internals of [[FlightGear]] are being exposed to the [[Property Tree]] than ever before. This allows us to have user level access in areas of the code that used to only be reserved for [[Programming Resources|programmers]]. Because of the manner in which the [[Property Tree]] is fed information, and the one step removed from the C source, care must be taken in how it is used. Depending on how it is used it won't be as responsive to manipulation as it would be if you were to change the same information at the C source level.
=== Effects File ===
The effects file is the mechanism we use to combine and manipulate all the necessary data to create stunning visual effects. It's the link between the data contained and produced in [[Nasal|Nasal]], [[Xml|XML]] and the [[Property Tree ]] and the graphics rendering pipeline. It's there to allow us to create these affects without having to know or use the C++ code base. Its flexible framework allows for an almost infinite range of sophisticated effects.
==== Parameters ====
Parameter entries defined in the Effect file correspond to a property tree [[Property Tree]] data container (static or variable). They will contain the data needed by the shader program to perform its magic. The type of information contained in the property tree [[Property Tree]] might be program control data or variable/static data that the shader program can manipulate prior to sending on to render.
In the case of ALS Lights, below is some of the data passed to, and used by, the shader program.
<syntaxhighlight lang="xml">
Note the "use-searchlight" entry, it is pointing to the use-searchlight entry in the property tree [[Property Tree]] under "sim/rendering/als-secondary-lights" that was defined in preferences.xml.
Some of this data may play a duel role inside the shader program. In other words it might be used to control other functions in addition to ALS Lights.
Note how "use_searchlight" is used in the main function to determine if the property defined in preferences.xml and manipulated in the property tree [[Property Tree]] is set to true or 1.
Some of the variable data contained in the shader program is used for other purposes and is introduced into the shader program from other property, parameter and uniform definitions not pertaining to ALS Lights.

Navigation menu