Howto:Shader programming in FlightGear: Difference between revisions

Jump to navigation Jump to search
m
Line 94: Line 94:
Restrictions: Cannot access any vertex other than the current one
Restrictions: Cannot access any vertex other than the current one


Note: Loading a vertex shader turns off parts of the OpenGL pipeline (vertex shaders fully replace the "T&L Unit")
Note: Loading a vertex shader turns off parts of the OpenGL pipeline (vertex shaders fully replace the "Texturing & Lighting unit")


Vertex shaders operate on every vertex, the vertex shader is executed for each vertex related OpenGL call (e.g. glVertex* or glDrawArrays).
Vertex shaders operate on each vertex, the vertex shader is executed for every vertex related OpenGL call (e.g. glVertex* or glDrawArrays).
A vertex shader provides almost full control over what is happening with each vertex. Consequently, all Per-Vertex operations of the fixed function OpenGL pipeline are replaced by the custom vertex shader.  
Accordingly, this means for example, that for meshes that contain e.g. 5000 vertices, the vertex shader will also be executed 5000 times.
 
A single vertex itself is composed of a number of "attributes" (vertex attrib), such as: position, texture coordinates, normal and color for the most common.
The position (attribute) is the most important one. The coordinates (x, y and z) of the vertex's entering position are those which have been given by the 3D modeler during the creation of the 3D model. The vertex's position is defined in the local space of the mesh (or object space).
 
A vertex shader provides almost full control over what is happening with each vertex. Consequently, all per-vertex operations of the fixed function OpenGL pipeline are replaced by the custom vertex shader.  


Vertex Shaders take application geometry and per-vertex attributes as input and transform the input data in some meaningful way.
Vertex Shaders take application geometry and per-vertex attributes as input and transform the input data in some meaningful way.
2,561

edits

Navigation menu