Howto:Shader programming in FlightGear: Difference between revisions

no edit summary
No edit summary
Line 347: Line 347:
= A Practical Application in [[Flightgear]] =
= A Practical Application in [[Flightgear]] =


== ALS Landing Lights ==
== ALS Landing Lights \ Spotlight ==
[[File:als secondary light.png|640px|thumbnail|Proof of Concept]]
[[File:als secondary light.png|640px|thumbnail|Proof of Concept]]
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 (we'll call it ALS Lights from now on) 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===
===Program Flow Simplified===
Line 369: Line 369:
*Parameters
*Parameters
Parameter entries defined in the Effect file correspond to a 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 might be program control data or variable/static data that the shader program can manipulate prior to sending on to render.
Parameter entries defined in the Effect file correspond to a 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 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  
In the case of ALS Lights, below is some of the data passed to, and used by, the shader.
 
<display_xsize><use>/sim/startup/xsize</use></display_xsize>
<display_ysize><use>/sim/startup/ysize</use></display_ysize>
<view_pitch_offset><use>/sim/current-view/pitch-offset-deg</use></view_pitch_offset>
<view_heading_offset><use>/sim/current-view/heading-offset-deg</use></view_heading_offset>
<view_fov><use>/sim/current-view/field-of-view</use></view_fov>
<use_searchlight><use>/sim/rendering/als-secondary-lights/use-searchlight</use></use_searchlight>
<use_landing_light><use>/sim/rendering/als-secondary-lights/use-landing-light</use></use_landing_light>
<use_alt_landing_light><use>/sim/rendering/als-secondary-lights/use-alt-landing-light</use></use_alt_landing_light>
<landing_light1_offset><use>/sim/rendering/als-secondary-lights/landing-light1-offset-deg</use></landing_light1_offset>
<landing_light2_offset><use>/sim/rendering/als-secondary-lights/landing-light2-offset-deg</use></landing_light2_offset>
<quality_level><use>/sim/rendering/shaders/landmass</use></quality_level>
<tquality_level><use>/sim/rendering/shaders/transition</use></tquality_level>


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.
*Shader Program
*Shader Program


330

edits