GLSL错误:“类型应为float或int”

时间:2017-10-29 21:35:08

标签: opengl glsl shader vertex-shader

我正在尝试编译着色器,它正在一台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

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

1 个答案:

答案 0 :(得分:5)

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

另外,仅供参考:当使用桌面GLSL(而不是GLSL ES)时,precision限定符无效。他们被忽略了;它们仅用于与GLSL ES着色器兼容。

相关问题