How to access vtkTexture in vtk shader?

I have used the tutorial Shaders In VTK - KitwarePublic to implement a basic shader in my python vtk program. I know that we can create a texture by using vtk.vtkTexture() class, but I don’t know how I can pass or use that in the shader. Can anyone provide some high-level comments to help on this? Thanks!


What are you trying to achieve?



Instead of rendering a point cloud data as mere points on the scene. I wanted to replace every point with a small patch of transparent PNG image. For that, I am trying to pass a texture image from the main python program to the vtk shaders. In C++ I would do the following to define the textures, but in my python program, I dont know how I can do this. Can I use PyOpenGL to initialize the texture images and then use it in vtk shaders? Will that work?

unsigned int texture;
glGenTextures(1, &texture);  
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);

My two cents: since we refer a texture (which resides in the graphics card) by its ID I see no problem in porting that to Python. Give it a try. See what happens.

1 Like