【问题标题】:GLSL texelFetchOffset works with isampler2D but not usampler2D?GLSL texelFetchOffset 适用于 isampler2D 但不适用于 usampler2D?
【发布时间】:2012-04-03 18:39:17
【问题描述】:

在片段着色器中,以下编译正常:

uniform isampler2D testTexture;
/* in main() x, y, xoff and yoff are declared as int and assigned here, then... */
int tmp = texelFetchOffset(testTexture, ivec2(x, y), 0, ivec2(xoff, yoff)).r;

但是,以下内容无法编译:

uniform usampler2D testTexture;
/* in main() x, y, xoff and yoff are declared as uint and assigned here, then... */
uint tmp = texelFetchOffset(testTexture, uvec2(x, y), 0, uvec2(xoff, yoff)).r;

OpenGL 4.2 驱动程序给出以下编译器错误消息:

错误 C1115:找不到兼容的重载函数“texelFetchOffset(usampler2D, uvec2, int, uvec2)

这是用于 Quadro 5010M 的 Nvidia 的 Linux 驱动程序 290.* —— 但我想知道我是否犯了(初学者)错误并且没有在此处以某种方式进行规范?

【问题讨论】:

    标签: opengl glsl fragment-shader texture2d render-to-texture


    【解决方案1】:

    采用usampler2DtexelFetchOffset 函数still 采用ivec2 作为其纹理坐标和偏移量。 u 仅适用于采样器类型和返回值;并非函数的所有内容都变为无符号。

    请记住:OpenGL 不允许在无符号和有符号整数类型之间进行隐式转换。

    【讨论】:

    • 我以为我已经尝试过了——但一定是这样。关于转换,是的,我强制使用 [#version 420 core] 配置文件,因此通常在不进行任何显式转换时,我会得到适当的警告。再次感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-31
    • 2020-11-23
    • 2018-09-08
    相关资源
    最近更新 更多