2017-08-09 3 views
0

Ich benutze Glumpy und ich versuche, eine Textur als GL_RGB32F zu binden. Es scheint, dass es die Textur als GL_RGB bindet, obwohl mein numpy Array vom Typ np.float32 ist. Die Werte dieses Arrays liegen außerhalb des Bereichs 0..1 und ich brauche diese Werte in einem Fragment-Shader, der nicht geclippt ist.glumpy.gloo Bindung Textur als GL_RGB32F

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) 

Der Ausgang ist

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

Wie kann ich die matte Array als GL_RGB32F und die distanceField als GL_R32F binden?

Antwort

0

Die Antwort gefunden. Verwenden Sie view(gloo.TextureFloat2D) auf dem Nummernfeld, andernfalls intern würde es automatisch view(Texture2D) aufrufen.

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