以二维纹理数组为例
texture(tex, vec3(x, y, index))
实际会取到的纹理由 index 四舍五入得到。此外,index 使用时会被限制在 0 ~ 数组大小 – 1 之间
如果有一个三层的纹理数组
index 为 -1 则取第一个;为 1.2 取第二个;为 1.9 取第三个(你可以理解为强制 GL_NEAREST)
以二维纹理数组为例
texture(tex, vec3(x, y, index))
实际会取到的纹理由 index 四舍五入得到。此外,index 使用时会被限制在 0 ~ 数组大小 – 1 之间
如果有一个三层的纹理数组
index 为 -1 则取第一个;为 1.2 取第二个;为 1.9 取第三个(你可以理解为强制 GL_NEAREST)
vec3 rgb(float h, float s, float v)
{
int hi = int(mod(floor(h / 60), 6));
float f = h / 60 - hi;
float p = v * (1 - s);
float q = v * (1 - f * s);
float t = v * (1 - (1 - f) * s);
switch(hi)
{
case 0:
return vec3(v, t, p);
case 1:
return vec3(q, v, p);
case 2:
return vec3(p, v, t);
case 3:
return vec3(p, q, v);
case 4:
return vec3(t, p, v);
case 5:
return vec3(v, p, q);
}
}
请看以下代码:
// ...
uniform struct
{
struct
{
vec3 pos;
} list[10];
} lights;
// ...
有的显卡可以正常处理以上定义,有的不行(即禁止在结构中定义结构)。
请改用以下方式声明:
// ...
struct whatever
{
vec3 pos;
};
uniform struct
{
struct whatever list[10];
} lights;
// ...