我将一个统一数组传递给几何着色器,并希望使用变量索引它.我可以使用带有固定数字的可变长度数组和索引(数字常量)或者我可以使用varible定义固定长度的数组和索引.但是我无法使用变量索引到可变长度数组.
下面是几何着色器的伪代码,其中包含无效的案例和案例
这有效:
uniform vec2 dimensions[2];
// some code which computes index which is an int
float dimX = dimensions[index].x;
Run Code Online (Sandbox Code Playgroud)
这有效:
uniform vec2 dimensions[];
// some code which computes index which is an int
float dimX = dimensions[0].x;
Run Code Online (Sandbox Code Playgroud)
这不起作用:
uniform vec2 dimensions[];
// some code which computes index which is an int
float dimX = dimensions[index].x;
Run Code Online (Sandbox Code Playgroud)
可以这样做吗?