GLSL Error: "Type should be float or int"
GLSL Error: "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
限定符不能应用于采样器类型。或 int
或 float
.
以外的任何类型
另外,仅供参考:当使用桌面 GLSL(与 GLSL ES 相对)时,precision
限定符没有任何作用。他们被忽略了;它们的存在仅仅是为了与 GLSL ES 着色器兼容。
我正在尝试编译一个着色器,它在一台 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
限定符不能应用于采样器类型。或 int
或 float
.
另外,仅供参考:当使用桌面 GLSL(与 GLSL ES 相对)时,precision
限定符没有任何作用。他们被忽略了;它们的存在仅仅是为了与 GLSL ES 着色器兼容。