跨平台图形程序使用以 GLSL 1.40 版编写的着色器。
GLSL 1.40 的特性完全满足了应用的需求。事实上,基本的着色器是用来绘制纹理的:
顶点着色器:
attribute vec2 position;
attribute vec2 textureCoordinates;
uniform mat3 transformationProjectionMatrix;
varying vec2 interpolatedTextureCoordinates;
void main() {
interpolatedTextureCoordinates = textureCoordinates;
gl_Position.xywz = vec4(transformationProjectionMatrix * vec3(position, 1.0), 0.0);
}
片段着色器:
precision mediump float;
uniform vec4 color;
uniform sampler2D textureData;
varying vec2 interpolatedTextureCoordinates;
void main() {
gl_FragColor.rgba = color * texture(textureData, interpolatedTextureCoordinates).bgra;
}
在程序中为不同版本的 GLSL 设置多个着色器是否有意义,这些着色器将根据特定硬件的支持进行选择?
使用更现代版本的着色器语言时是否可以获得加速?