The examples are in C++ and have include directives for these .h header files. There few, if any Python 3 examples. The only Python package/module that can be imported are vtk and vtkmodules. Importing vtk seem to imply importing vtkmodules, based on len(sys.modules)
Importing vtk, I can not find any modules, classes or methods with ‘shader’ in the name.
And both vtk and vtkmodules have an ‘all’ sub-module, but:
from vtk import all
get a lot more than:
import vtk
len(sys.modules) is 166 after import vtk and 293 after import all from vtk.
I am confused about how to use GLSL shaders with VTK in Python3. All of this is done using the Python 3.9.13 that came with ParaVIew 5.11.1. Please help!
Yes! Thank you. I meant to come back and answer my own question, but I wanted to get my code working first.
What I learned, for the sake of others who have the same question(s). Please correct me if I am wrong about anything.
In Python, the vtk and vtkmodules packages allow access to the VTK objects. However they are (very) different versions. vtkmodules has most or all of vtk, plus a whole lot more. In addition, everything is broken down in to sub-modules for better organization.
Sub-modules are not imported by default, allowing finer grain importing. I have to import each class I need, but that means I don’t have to import everything.
The example code I was starting from imported the vtk module. Our installation of python allowed that, but the actual libraries couldn’t be found. Either they aren’t there or require a different environment to get to them.
I was able to find all of the calls in the example code within sub-modules and was able change them to work with vtkmodules.
Some things have change such that my example code can’t run with vtkmodules. For example, it seem one used to be able add a ShaderProgram to an actor, but in the current version, actor does not have a SetShaderProgram() method. I am currently working on learning the right way to do this and other things using vtkmodules.
The calss documentation on vtk.org make a lot more sense now that I understand the organization.
vtk is the “old” module. However, there wasn’t a way to make that compatible with the preferred way of only importing what is actually needed that vtkmodules allows. It is basically from vtkmodules.all import *, so the VTK classes should be no different between the two.
You might need a vtkOpenGLActor to get that method. Due to the object factories, you may need to import vtkRenderingOpenGL2 to ensure that the overrides are available there.
I also searched, I think, all of the different actors, and all of them only have SetShaderProperty(). There is a vtkShaderProgram class. I can’t find ‘SetShaderProgram’ anywhere in the VTK 9.2 documentation. VTK 7.1 is the last version I can find mention of it.
I’m mixing paradigms. I will follow the example for my code. Thanks!
My apologies I posted here because eventually, I want use what I’m working on in Paraview, so that’s where my mindset was. I will post pure VTK questions the VTK discourse.