0

I'm using Glumpy and I'm trying to bind a texture as GL_RGB32F. It appears that it binds the texture as GL_RGB, even though my numpy array is of type np.float32. The values this array contains are outside the 0..1 range, and I need these values in a fragment shader 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)

The output is

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

How can I bind the matte array as GL_RGB32F and the distanceField as GL_R32F?

4

1 回答 1

0

找到了答案。在 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)]
于 2017-08-09T13:26:49.990 回答