首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >glumpy.gloo将纹理绑定为GL_RGB32F

glumpy.gloo将纹理绑定为GL_RGB32F
EN

Stack Overflow用户
提问于 2017-08-09 20:24:19
回答 1查看 128关注 0票数 0

我正在使用Glumpy,并尝试将纹理绑定为GL_RGB32F。它似乎将纹理绑定为GL_RGB,即使我的numpy数组是np.float32类型的。此数组包含的值超出0..1范围,我需要在片段着色器中取消剪裁这些值。

代码语言:javascript
复制
compute = gloo.Program(compute_vertex, compute_fragment, count=4)
compute["matte"] = matte
compute["matte"].interpolation = gl.GL_NEAREST
compute["matte"].wrapping = gl.GL_CLAMP_TO_EDGE
compute["distanceField"] = alpha
compute["distanceField"].interpolation = gl.GL_NEAREST
compute["distanceField"].wrapping = gl.GL_CLAMP_TO_EDGE
compute["position"] = [(-1, -1), (-1, +1), (+1, -1), (+1, +1)]
compute["texcoord"] = [(0, 0), (0, 1), (1, 0), (1, 1)]

print(matte.dtype)
print(gl.GL_RGB32F)
print(compute["matte"].gpu_format)
print(compute["distanceField"].gpu_format)

输出为

代码语言:javascript
复制
float32
GL_RGB32F (34837)
GL_RGB (6407)
GL_RED (6403)

如何将matte数组绑定为GL_RGB32F,将distanceField绑定为GL_R32F

EN

回答 1

Stack Overflow用户

发布于 2017-08-09 21:26:50

找到答案了。在numpy数组上使用view(gloo.TextureFloat2D),否则它将在内部自动调用view(Texture2D)

代码语言:javascript
复制
compute = gloo.Program(compute_vertex, compute_fragment, count=4)
compute["matte"] = matte.view(gloo.TextureFloat2D)
compute["matte"].interpolation = gl.GL_NEAREST
compute["matte"].wrapping = gl.GL_CLAMP_TO_EDGE
compute["distanceField"] = alpha.view(gloo.TextureFloat2D)
compute["distanceField"].interpolation = gl.GL_NEAREST
compute["distanceField"].wrapping = gl.GL_CLAMP_TO_EDGE
compute["position"] = [(-1, -1), (-1, +1), (+1, -1), (+1, +1)]
compute["texcoord"] = [(0, 0), (0, 1), (1, 0), (1, 1)]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45590649

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档