Changes

Jump to: navigation, search

Howto:Shader programming in FlightGear

210 bytes removed, 07:42, 13 October 2014
no edit summary
=== Program Flow Simplified ===
Preferences/[[Nasal|Nasal]]/[[Xml|XML ]] >> [[Property Tree]] >> Effect File >> Shader >> Rendered to Screen
=== Preferences/Nasal/XML ===
Any combination of Preferences, [[Nasal |Nasal]] or [[Xml|XML ]] manipulates data in the [[Property Tree]].
In this case the switch to turn on the landing or spot light and a couple other needed data containers are defined in $FG_ROOT/preferences.xml with the following lines.
<als-secondary-lights>
<landing-light2-offset-deg type="float">0.0</landing-light2-offset-deg>
</als-secondary-lights>
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]].
=== Effects File ===
{{Note|need link to Effects Doc here to explain the details of the 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 ====
In the case of ALS Lights, so far we only have to deal with the fragment shader.
The program section of the effect file is a nifty method used to allow users to add shaders to [[Flightgear]] without having to add code at C level language base. The C level base is programed to recognize the [[Xml|XML ]] tag pair of <program></program> and thus incorporate the GLSL program files pointed to between the tags. Otherwise you would have to add the GLSL program calls in the base C requiring a completely different set of programming [[Programming Resources|programing]] skills and also the necessity of compiling [[Flightgear]] everytime you want to add new shader. It can work this way because shader programs are compiled at run-time.
We'll describe the contents of the shader programs below. For now, suffice it to say tree-ALS.frag contains the main program and secondary_lights.frag has functions that are passed uniform data that is manipulated and returned to main for processing.
{{WIP|more to follow}}
 
 
[[Xml|xml]]
[[Nasal|nasal]]
[[Nasal/CppBind|nasal]]
[[Nasal/JavaScript Subset|nasal]]
[[Nasal CDU Framework|nasal]]
[[Nasal Callbacks Explained|nasal]]
[[Nasal Conditionals|nasal]]
[[Nasal Display Matrix Framework|nasal]]
[[Nasal Events|nasal]]
[[Programming Resources|program]]
[[Modeling Resources|model]]
 
[[Category:Howto|Shader Programming in FlightGear]]
[[Category:Shader development]]
[[Category: Core developer documentation]]
266
edits

Navigation menu