Niklas R
Niklas R

Reputation: 16870

glumpy.gloo bind texture as GL_RGB32F

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?

Upvotes: 0

Views: 201

Answers (1)

Niklas R
Niklas R

Reputation: 16870

Found the answer. Use view(gloo.TextureFloat2D) on the numpy array, otherwise, internally it would automatically call 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)]

Upvotes: 0

Related Questions