[GLSL]Mipmap 相关函数

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

[GLSL]HSV 转为 RGB

1vec3 rgb(float h, float s, float v)
2{
3    int hi = int(mod(floor(h / 60), 6));
4    float f = h / 60 - hi;
5    float p = v * (1 - s);
6    float q = v * (1 - f * s);
7    float t = v * (1 - (1 - f) * s);
8    switch(hi)
9    {
10    case 0:
11        return vec3(v, t, p);
12    case 1:
13        return vec3(q, v, p);
14    case 2:
15        return vec3(p, v, t);
16    case 3:
17        return vec3(p, q, v);
18    case 4:
19        return vec3(t, p, v);
20    case 5:
21        return vec3(v, p, q);
22    }
23}
glsl

参考:颜色空间RGB与HSV(HSL)的转换_hsb色彩模式圆椎形-CSDN博客

  • 2021/8/17
  • OpenGL

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

请看以下代码:

1// ...
2
3uniform struct
4{
5    struct
6    {
7        vec3 pos;
8    } list[10];
9} lights;
10
11// ...
glsl

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

请改用以下方式声明:

1// ...
2
3struct whatever
4{
5    vec3 pos;
6};
7
8uniform struct
9{
10     struct whatever list[10];
11} lights;
12
13// ...
glsl
  • 2021/8/10
  • OpenGL