GLSL 错误:"Type should be float or int"



我正在尝试编译着色器,它正在一台PC上的Intel HD上编译,而不是在另一台PC上的AMD驱动程序上编译。

顶点着色器:

#version 330
precision mediump float;
precision lowp sampler2D;
uniform mat4 ProjectionMatrix;
uniform mat4 ModelViewMatrix;
uniform mat4 WorldViewMatrix;
in vec3 position;
in vec2 TexCoord;
out vec2 texCoord;
void main() {
    texCoord = TexCoord;
    gl_Position = ProjectionMatrix * ModelViewMatrix * WorldViewMatrix * vec4(position, 1);
}

片段着色器:

#version 330
precision mediump float;
precision lowp sampler2D;
uniform vec4 TextureHueColor;
uniform sampler2D TextureUnit;
in vec2 texCoord;
out vec4 gl_FragColor;
void main() {
    gl_FragColor = texture(TextureUnit, texCoord) * TextureHueColor;
}

在AMD驱动程序上,我得到:

Vertex shader failed to compile with the following errors:
ERROR: 0:3: error(#228) Type should be float or int
ERROR: error(#273) 1 compilation errors.  No code generated

我是初学者,不知道这个着色器有什么问题,对我来说它看起来不错。有人发现出了什么问题吗?

GLSL 3.30 中的默认precision限定符不能应用于采样器类型。或除intfloat以外的任何类型。

另外,仅供参考:当使用桌面 GLSL(与 GLSL ES 相反)时,precision限定符什么也做不了。它们被忽略;它们的存在只是为了与 GLSL ES 着色器兼容。

相关内容

最新更新