[OpenGL]纹理数组的一些小细节

以二维纹理数组为例

texture(tex, vec3(x, y, index))

实际会取到的纹理由 index 四舍五入得到。此外,index 使用时会被限制在 0~数组大小–1 之间

如果有一个三层的纹理数组

index 为-1 则取第一个;为 1.2 取第二个;为 1.9 取第三个(你可以理解为强制 GL_NEAREST)

OpenGL



[GLSL]Mipmap 相关函数

  • int textureQueryLevels(sampler):返回该材质 Mipmap 数量
  • vec2 textureQueryLod(sampler, vec2):返回 Mipmap 与 LOD 所在等级
OpenGL

[OpenGL]error C7539: GLSL 1.20 does not allow nested structs

请看以下代码:

// ...

uniform struct
{
    struct
    {
        vec3 pos;
    } list[10];
} lights;

// ...

有的显卡可以正常处理以上定义,有的不行(即禁止在结构中定义结构)。

请改用以下方式声明:

// ...

struct whatever
{
    vec3 pos;
};

uniform struct
{
     struct whatever list[10];
} lights;

// ...
OpenGL