Changes

Jump to: navigation, search

Howto:Shader programming in FlightGear

10 bytes removed, 18:20, 8 March 2011
m
Robot: Cosmetic changes
Note: Loading a vertex shader turns off parts of the OpenGL pipeline (vertex shaders fully replace the "Texturing & Lighting unit")
Objects in a computer graphics scene are usually meshes that are made up of polygons. The corner of each of those polygons is called a "vertex".
A vertex shader receives input in the form of per-vertex variables called "attribute variables", and per-polygon variables called "uniform variables".
The vertex shader must specify the coordinates of the vertex in question. This way, the geometry of the object can be modified.
A vertex shader can also set other variables which are called "varying variables".
The values of these variables are passed on to the second kind of shader, the "fragment shader".
The fragment shader is run for every pixel on the screen where the polygons of the mesh appear.The fragment shader is responsible for setting the final color of that little piece of the mesh
== Matrices ==
* mat2 2x2 floating point matrix* mat3 3x3 floating point matrix
* mat4 4x4 floating potint matrix
* const - for declaring non-writable, compile-time constant variables
* attribute - For frequently changing (per vertex) information passed from the application to a vertex shader (no integers, bools, structs, or arrays)
* uniform - for infrequently changing (per primitive) information passed from the application to a vertex or fragment shader:constant shader parameters that can be changed between draws (cannot be written to in a shader, do not change per-vertex or per-fragment)
* varying - for information passed from a vertex shader to a fragment shader, will be interpolated in a perspective-correct manner during rasterization (can write in vertex shader, but only read in fragment shader)
== Vertex Shader ==
* vec4 gl_Position; must be written
* vec4 gl_ClipPosition; may be written
* float gl_PointSize; may be written
== Fragment Shader ==
* float gl_FragColor; may be written
* float gl_FragDepth; may be read/written* vec4 gl_FragCoord; may be read
* bool gl_FrontFacing; may be read
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}
 
[[Category:Howto|Shader Programming in FlightGear]]
4,400
edits

Navigation menu