Add GLSL shader to a VTKActor (VTK 6.1)

glsl, opengl, vtk

Solution

The solution finally appeared in vtk mailing list after months of waiting! I didn't test it myself, but user @carlinhos says it works. He resumes the steps:

- Create a shader file with the function propFuncFS(Fragment shader) or propFuncVS(Vertex shader).

- Load the shader from disk.

- Create a vtkShader2 and set the source code.

- Create a vtkShaderProgram2 and initialize it (DO NOT BUILD THE PROGRAM).

- Add the shader to the program.

- Obtain the actor vtkOpenGLProperty and set the program

- Set the shading on.

EDIT: Is @carlinhos you? I am feeding you your own answer? :)

Problem

I'm trying to add a shader to a vtkActor into my application. I have different vtkActors and they must have different shaders each one. I tried with the vtkShader2, vtkShaderProgram2 and vtkOpenGLProperty to set the program loaded with the shader to the actor, but it didn't work (vtk told me in a warning window that it has 4 shaders in the actor, the default shaders and mine). Someone knows the right way to do it?

Original source