1

我有一个片段着色器,具有以下内容:

const lowp float colors[8] = float[8]( // line 12
    0,0,0,1,
    1,0,0,1
);

但它无法编译:

ERROR: 0:12: 'array of float' : array type not supported here in glsl < 120 
ERROR: 0:12: 'array of float' : constructor not supported for type 
ERROR: 0:15: 'array of float' : no matching overloaded function found 
ERROR: 0:12: 'const lowp float' : cannot declare arrays of this type 
ERROR: 0:12: 'colors' : redefinition 

如何在 GLSL 中定义查找表?输入纹理具有来自枚举的值,我希望将每个值映射到不同的颜色。

4

2 回答 2

2

您可以使用一维纹理作为查找表。

于 2010-06-23T15:27:31.987 回答
1

阅读规范,第 4.1.9 节:

“没有在声明时从着色器中初始化数组的机制。”

于 2010-06-23T15:15:58.940 回答