Howto:Shader programming in FlightGear: Difference between revisions

m
Line 19: Line 19:


= What is a Shader =
= What is a Shader =
A shader is a programmable replacement for parts of the fixed function OpenGL pipeline.
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 offer:
Shaders offer:
Line 33: Line 34:
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.  


Shaders will be compiled when the 3D application starts. They will be validated and optimized for the current hardware.


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 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).


Each Shader program is assigned an handler, and you can have as many programs linked and ready to use as you want (and your hardware allows).
Each Shader program is assigned an handler, and you can have as many programs linked and ready to use as you want (and your hardware allows).
Once rendering, we can switch from program to program, and even go back to fixed functionality during a single frame  
Once rendering, we can switch from program to program, and even go back to fixed functionality during a single frame.


To really understand shaders, you should have a knowledge about the rendering pipeline; this helps to understand where and when the shaders act in the rendering process. In general, you must know that vertex are collected, processed by vertex shaders, primitives are built, then are applied colors, textures and are also called fragment shaders; finally it comes to the rasterization and the frame is put on the buffer.  
To really understand shaders, you should have a knowledge about the rendering pipeline; this helps to understand where and when the shaders act in the rendering process. In general, you must know that vertex are collected, processed by vertex shaders, primitives are built, then are applied colors, textures and are also called fragment shaders; finally it comes to the rasterization and the frame is put on the buffer.  
2,561

edits