To Be Continued...
[Conception]
storage qualifiers
[URL]
[]
...
As we have already learned, programming shaders is one of the core requirements when using OpenGL. Shader programs are written in a high level language called The OpenGL Shading Language (GLSL), which is a language very similar to C. To install a shader program, the shader source code has to be sent to the graphics card as a string, where the program then needs to be compiled and linked. The language specifies various types suited to its needs.
To define the linkage between different shaders as well as between shaders and the application, GLSL provides variables with extra functionality by using storage qualifiers. These storage qualifiers need to be written before the type name during declaration.
Storage Qualifier Description
---------------------------------------------------------------------------
none (default) Normal variable.
const Compile-time constant
attribute
uniform
varying
--------------------------------------------------------------------------
To send data from the vertex shader to the fragment shader, the out variable of the vertex shader and the in variable of the fragment shader need to share the same name. Since there are usually a lot of fragments in between a few vertices, the data calculated by the vertex shader is by default interpolated in a perspective correct manner. To enforce this behavior, the additional qualifier smooth can be written before in. To use linear interpolation, the noperspective qualifier can be set. Interpolation can be completely disabled by using flat. Then, for all the fragments in between a primitive, the value output by the first vertex of this primitive is used.
This kind of variables are commonly called varyings, due to this interpolation and because in earlier versions of OpenGL this shader-to-shader linkage was achieved using a variable qualifier called varying instead of in and out....
[]
...
...
[]
...
...
...
...
[]
...
...
...
...
[]
...
...
...
...
No comments:
Post a Comment