Howto:Shader programming in FlightGear: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 373: Line 373:


=== Program Flow Simplified ===
=== Program Flow Simplified ===
Preferences/[[Nasal]]/XML >> [[Property Tree]] >> Effect File >> Shader >> Rendered to Screen
Preferences/[[Nasal|Nasal]]/[[Xml|XML]] >> [[Property Tree]] >> Effect File >> Shader >> Rendered to Screen


=== Preferences/Nasal/XML ===  
=== Preferences/Nasal/XML ===  
Any combination of Preferences, Nasal or XML manipulates data in the [[Property Tree]].  
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.
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>
  <als-secondary-lights>
Line 385: Line 385:
   <landing-light2-offset-deg type="float">0.0</landing-light2-offset-deg>
   <landing-light2-offset-deg type="float">0.0</landing-light2-offset-deg>
  </als-secondary-lights>
  </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 calls or XML.
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 ===
=== Effects File ===
{{Note|need link to Effects Doc here to explain the details of the 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, 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.
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 ====
==== Parameters ====
Line 424: Line 424:
In the case of ALS Lights, so far we only have to deal with the fragment shader.
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 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 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.
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 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.
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.
Line 767: Line 767:


{{WIP|more to follow}}
{{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:Howto|Shader Programming in FlightGear]]
[[Category:Shader development]]
[[Category:Shader development]]
[[Category: Core developer documentation]]
[[Category: Core developer documentation]]
330

edits