glsl限定符
Attribute
Vertex attribute data.
Example
attribute vec4 v_color;
Description
attribute read-only variables containing data shared from WebGL/OpenGL environment to the vertex shader.
Because the vertex shader is executed one time for each vertex, attributes are specify per vertex data typically with information such as: space position, color, normal direction and texture coordinates of a vertex.
Const
Constant qualifier
Example
const float PI = 3.14159265359;
Description
const qualifier can be applied to the declaration of any variable to specify that its value will not be changed.
Uniform
Uniform variable qualifier.
Example
uniform vec4 direction;
Description
uniform variables contain read-only data shared from WebGL/OpenGL environment to a vertex or fragment shader.
The value is per primitive, so is useful for variables which remain constant along a primitive, frame or scene.
Varying
Varying variable qualifier.
Example
varying vec3 position;
Description
varying variables contain data shared from a vertex shader to a fragment shader.
The variable must be written in the vertex shader and the read-only value in the fragment shader is then interpolated from the vertices which make up the fragment.
本文探讨了GLSL中的关键特性,包括attribute(顶点属性)用于传递顶点数据,如颜色和位置;const(常量)确保变量值不变;uniform(统一变量)共享环境数据;以及varying( varyings)在顶点和片段之间传递数据。精度关键字如highp和mediump也有所提及。

被折叠的 条评论
为什么被折叠?



