gpt4 book ai didi

c++ - OpenGL片段着色器未在Intel HD 4000图形上编译

转载 作者:行者123 更新时间:2023-12-01 14:47:43 30 4
gpt4 key购买 nike

在我的ryzen 3 2200g上的Vega 8 iGPU上,此着色器似乎可以正常编译,但同一片段着色器在intel hd 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编译器的实际字符串,但没有区别。

我真的不确定是什么问题。

最佳答案

英特尔HD 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;
}
}

谢谢!

关于c++ - OpenGL片段着色器未在Intel HD 4000图形上编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62213911/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com