OpenGL 片段着色器未在英特尔 HD 4000 显卡上编译
OpenGL Fragment Shader not compiling on Intel HD 4000 graphics
这个着色器似乎在我的锐龙 8 2200g 上的 Vega 3 iGPU 上编译得很好,但相同的片段着色器无法在英特尔高清 4000 显卡上编译。真的存在着色器错误或我做错了什么吗?我还采取措施不使用int
来指代制服。请帮忙。
#version 330 core
in vec2 TexCoord;
// I am using a batch rendering method. The "TexElement" is the slot to which the texture is bound to
in flat int TexElement;
// Color to multiply with the texture color also called tint
in flat vec4 MultiplyColor;
// Outputted color
out vec4 color;
uniform sampler2D u_Textures[32];
void main()
{
switch (TexElement)
{
case 0 : color = texture(u_Textures[0], TexCoord) * MultiplyColor; break;
case 1 : color = texture(u_Textures[1], TexCoord) * MultiplyColor; break;
case 2 : color = texture(u_Textures[2], TexCoord) * MultiplyColor; break;
case 3 : color = texture(u_Textures[3], TexCoord) * MultiplyColor; break;
case 4 : color = texture(u_Textures[4], TexCoord) * MultiplyColor; break;
case 5 : color = texture(u_Textures[5], TexCoord) * MultiplyColor; break;
case 6 : color = texture(u_Textures[6], TexCoord) * MultiplyColor; break;
case 7 : color = texture(u_Textures[7], TexCoord) * MultiplyColor; break;
case 8 : color = texture(u_Textures[8], TexCoord) * MultiplyColor; break;
case 9 : color = texture(u_Textures[9], TexCoord) * MultiplyColor; break;
case 10 : color = texture(u_Textures[10], TexCoord) * MultiplyColor; break;
case 11 : color = texture(u_Textures[11], TexCoord) * MultiplyColor; break;
case 12 : color = texture(u_Textures[12], TexCoord) * MultiplyColor; break;
case 13 : color = texture(u_Textures[13], TexCoord) * MultiplyColor; break;
case 14 : color = texture(u_Textures[14], TexCoord) * MultiplyColor; break;
case 15 : color = texture(u_Textures[15], TexCoord) * MultiplyColor; break;
case 16 : color = texture(u_Textures[16], TexCoord) * MultiplyColor; break;
case 17 : color = texture(u_Textures[17], TexCoord) * MultiplyColor; break;
case 18 : color = texture(u_Textures[18], TexCoord) * MultiplyColor; break;
case 19 : color = texture(u_Textures[19], TexCoord) * MultiplyColor; break;
case 20 : color = texture(u_Textures[20], TexCoord) * MultiplyColor; break;
case 21 : color = texture(u_Textures[21], TexCoord) * MultiplyColor; break;
case 22 : color = texture(u_Textures[22], TexCoord) * MultiplyColor; break;
case 23 : color = texture(u_Textures[23], TexCoord) * MultiplyColor; break;
case 24 : color = texture(u_Textures[24], TexCoord) * MultiplyColor; break;
case 25 : color = texture(u_Textures[25], TexCoord) * MultiplyColor; break;
case 26 : color = texture(u_Textures[26], TexCoord) * MultiplyColor; break;
case 27 : color = texture(u_Textures[27], TexCoord) * MultiplyColor; break;
case 28 : color = texture(u_Textures[28], TexCoord) * MultiplyColor; break;
case 29 : color = texture(u_Textures[29], TexCoord) * MultiplyColor; break;
case 30 : color = texture(u_Textures[30], TexCoord) * MultiplyColor; break;
case 31 : color = texture(u_Textures[31], TexCoord) * MultiplyColor; break;
default : color = MultiplyColor; break;
}
}
这是glInfoLog:
ERROR: 0:19: 'u_Textures' : undeclared identifier
ERROR: 0:19: 'u_Textures' : left of '[' is not of type array, matrix, or vector
ERROR: 0:19: 'texture' : no matching overloaded function found (using implicit conversion)
ERROR: 0:20: 'u_Textures' : left of '[' is not of type array, matrix, or vector
ERROR: 0:20: 'texture' : no matching overloaded function found (using implicit conversion)
ERROR: 0:21: 'u_Textures' : left of '[' is not of type array, matrix, o
我还验证了传递给 GLSL 编译器的实际字符串,但没有区别。
我真的不确定问题是什么。
英特尔核芯 4000 显卡仅支持多达 16 个纹理插槽或单元。您正在接收大小为 32 的 sampler2D 数组。超过16。如果您将数组大小更改为 16 并注释掉多余的情况,它将起作用。这是更新的着色器代码:
#version 330 core
in vec2 TexCoord;
// I am using a batch rendering method. The "TexElement" is the slot to which the texture is bound to
in flat int TexElement;
// Color to multiply with the texture color also called tint
in flat vec4 MultiplyColor;
// Outputted color
out vec4 color;
uniform sampler2D u_Textures[16];
void main()
{
switch (TexElement)
{
case 0 : color = texture(u_Textures[0], TexCoord) * MultiplyColor; break;
case 1 : color = texture(u_Textures[1], TexCoord) * MultiplyColor; break;
case 2 : color = texture(u_Textures[2], TexCoord) * MultiplyColor; break;
case 3 : color = texture(u_Textures[3], TexCoord) * MultiplyColor; break;
case 4 : color = texture(u_Textures[4], TexCoord) * MultiplyColor; break;
case 5 : color = texture(u_Textures[5], TexCoord) * MultiplyColor; break;
case 6 : color = texture(u_Textures[6], TexCoord) * MultiplyColor; break;
case 7 : color = texture(u_Textures[7], TexCoord) * MultiplyColor; break;
case 8 : color = texture(u_Textures[8], TexCoord) * MultiplyColor; break;
case 9 : color = texture(u_Textures[9], TexCoord) * MultiplyColor; break;
case 10 : color = texture(u_Textures[10], TexCoord) * MultiplyColor; break;
case 11 : color = texture(u_Textures[11], TexCoord) * MultiplyColor; break;
case 12 : color = texture(u_Textures[12], TexCoord) * MultiplyColor; break;
case 13 : color = texture(u_Textures[13], TexCoord) * MultiplyColor; break;
case 14 : color = texture(u_Textures[14], TexCoord) * MultiplyColor; break;
case 15 : color = texture(u_Textures[15], TexCoord) * MultiplyColor; break;
default : color = MultiplyColor; break;
}
}
谢谢!
相关文章:
- OpenGL 片段着色器未在英特尔 HD 4000 显卡上编译
- 为什么 MSVC C++编译器将一个简单的 Hello World 扩展为 4000 行汇编?
- 读取数组的第一个元素还是第 4000 个元素更快?
- 将 OpenGL 兼容性配置文件与英特尔 HD GPU + Mesa 结合使用
- OpenCL could not found Intel HD 4000
- 构建最终应用程序时,如何将HD映像从HD打包到.EXE文件中
- 有效地找到一个不在40、400或4000尺寸的整数
- C Windap没有返回所有条目.停在4000
- 如何在Ati Radeon HD 4850和Ati Radeon HD4830之间确定图形卡
- 获取HD/分区序列号
- 如何在没有root权限的情况下在Linux中读取HD串行
- 如何知道设备 /dev/hd* 是否是 Linux 中的 CDROM,带有 C/C++
- 睡眠(4000)秀.对于每1000(C++)
- 使用ATI Mobility Radeon HD 5850图形卡执行计算
- APK资产未在Kindle Fire HD上加载
- 将颜色传递给英特尔 HD 4000 上 Assimp 模型的 GLSL 着色器 1.40
- 错误:将'char*'分配给'char [4000]'的类型不兼容
- windows 7, qt 5.7, Intel (HD) Graphics Family, OpenGL V 3.1
- 如何在Ubuntu 15.04上运行OpenGL 3.3版本(与Intel HD 4000)
- 如何在MacOS和Intel HD 3000上使用opengl3.0