Jump to: navigation, search

Howto:Shader programming in FlightGear

422 bytes added, 20:18, 26 March 2010
Shader Types
= Shader Types =
There are two types of shaders in GLSL: "vertex shaders" and "fragment shaders"(with geometry shaders being a part of OpenGL 3.2). 
These are executed by vertex and fragment processors in the graphics hardware.
 * Vertex shaders transform vertices, set up data for fragment shaders* Fragment shaders operate on fragments generated by rasterization* Geometry shaders create geometry on the GPU Typically, vertex shader files use the file extension ".vert", while fragment shader files use the ".frag" extension. In FlightGear, these files can be found in the "Shaders" subdirectory of the base package, i.e. $FG_ROOT/Shaders 
For a list of currently available shaders, you may want to take a look at:
A vertex shader is run once per vertex, while a fragment shader is run once per pixel.
Many such executions can happen in parallel. There is no communication or ordering between
executions. Vertex shaders are flexible and quick.
Vertex shaders are flexible and quick
* Vertex color computation
* Geometry skinning
* Animation
* Setting up data for fragment shaders
The vertex shader runs from start to end for each and every vertex that's passed into the graphics card - the fragment process does the same thing at the pixel level. In most scenes there are a heck of a lot more pixel fragments than there are vertices - so the performance of the fragment shader is vastly more important and any work we can do in the vertex shader, we probably should.
Common tasks of fragment shaders include:
* Texturing (even procedural)
* Per pixel lightingand material application* ray tracing
* Fragment color computation
* Operations on Interpolated Values
* Doing operations per fragment to make pretty pictures

Navigation menu