Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add GLSL shader to a VTKActor (VTK 6.1)

Tags:

opengl

glsl

vtk

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?

like image 624
mpcarlos87 Avatar asked Jul 07 '14 16:07

mpcarlos87


1 Answers

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:

  1. Create a shader file with the function propFuncFS(Fragment shader) or propFuncVS(Vertex shader).
  2. Load the shader from disk.
  3. Create a vtkShader2 and set the source code.
  4. Create a vtkShaderProgram2 and initialize it (DO NOT BUILD THE PROGRAM).
  5. Add the shader to the program.
  6. Obtain the actor vtkOpenGLProperty and set the program
  7. Set the shading on.

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

like image 115
Nil Avatar answered Oct 04 '22 07:10

Nil