Howto:Shader programming in FlightGear: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 351: Line 351:
The ALS Landing Lights/Spotlight is a good example for showing how to incorporate a shader effect into [[Flightgear]] as it touches many parts of the visuals we see and many parts of the coding pipeline.
The ALS Landing Lights/Spotlight is a good example for showing how to incorporate a shader effect into [[Flightgear]] as it touches many parts of the visuals we see and many parts of the coding pipeline.


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


{{Note|add pipeline flow here}}
===Preferences/Nasal/XML===
Any combination of Preferences, Nasal or 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>
  <use-searchlight type="bool">false</use-searchlight>
  <use-landing-light type="bool">false</use-landing-light>
  <use-alt-landing-light type="bool">false</use-alt-landing-light>
  <landing-light1-offset-deg type="float">0.0</landing-light1-offset-deg>
  <landing-light2-offset-deg type="float">0.0</landing-light2-offset-deg>
</als-secondary-lights>
 
===Effects File===
{{Note|need link to Effects Doc here}}
*Parameters
Parameters
*Shader Program
 
*Uniforms
 
===Shader Program===
*Uniform Input
 
*Variable Assignments
 
*Main Program




Line 407: Line 433:
*** fragment water-ALS-high.frag & secondary_lights.frag
*** fragment water-ALS-high.frag & secondary_lights.frag
** adds uniforms (technique 2)
** adds uniforms (technique 2)




330

edits