闷闷不乐的将纹理绑定为GL\u RGB32F

2024-09-30 06:14:35 发布

您现在位置:Python中文网/ 问答频道 /正文

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

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)

输出为

float32
GL_RGB32F (34837)
GL_RGB (6407)
GL_RED (6403)

如何将matte数组绑定为GL_RGB32F,将distanceField绑定为GL_R32F?你知道吗


Tags: rgb数组printcompute纹理glfloat32nearest
1条回答
网友
1楼 · 发布于 2024-09-30 06:14:35

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

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)]

相关问题 更多 >

    热门问题