Howto:Shader programming in FlightGear: Difference between revisions

m
Line 21: Line 21:
A shader is a programmable replacement for parts of the fixed function OpenGL pipeline, you can imagine it sort of like a "plugin" to customize rendering.
A shader is a programmable replacement for parts of the fixed function OpenGL pipeline, you can imagine it sort of like a "plugin" to customize rendering.
Shaders will be compiled when the 3D application starts. They will be validated and optimized for the current hardware.
Shaders will be compiled when the 3D application starts. They will be validated and optimized for the current hardware.
GLSL shaders are not stand-alone applications; they require an application that utilizes the OpenGL API.
A shader is a program, to be run it must be loaded, compiled and linked. Actually each vertex and fragment shader must have one entry point (the main function) each, but you can create and link more shaders.
GLSL shaders themselves are simply a set of strings that are passed to the hardware vendor’s driver for compilation from within an application using the OpenGL API’s entry points. Shaders can be created on the fly from within an application or read in as text files, but must be sent to the driver in the form of a string.
GLSL has explicit ties to the OpenGL API - to the extent that much of the OpenGL 'state' (eg which light sources are bound, what material properties are currently set up) is presented as pre-defined global variables in GLSL.


Shaders offer:
Shaders offer:
Line 33: Line 41:


To make it simple, a shader is a program that is loaded on the GPU and called for every vertex or pixel: this gives programmers the possibility to implement techniques and visual effects and execute them faster. In modern games or simulators lots of shaders are used: lights, water, skinning, reflections and much more.  
To make it simple, a shader is a program that is loaded on the GPU and called for every vertex or pixel: this gives programmers the possibility to implement techniques and visual effects and execute them faster. In modern games or simulators lots of shaders are used: lights, water, skinning, reflections and much more.  


We can create as many shader programs as needed (you can have many shaders of the same type (vertex or fragment) attached to the same program, but only one of them can define the entrypoint:the main() function).
We can create as many shader programs as needed (you can have many shaders of the same type (vertex or fragment) attached to the same program, but only one of them can define the entrypoint:the main() function).
2,561

edits