Can I use OpenGL compute shaders in VTK program?

VTK9.0 use OpenGL2 at backend, and use GetOpenGLVersion result is 4.4.

i found vtkShader not contain compute shader.

Does anyone has any example to use compute shader?

thank you!

Hi, friend,

Since your post was not much specific, I can only suggest this example here: https://gitlab.kitware.com/vtk/vtk/blob/v7.0.0.rc2/Rendering/OpenGL2/Testing/Cxx/TestUserShader2.cxx . It includes a basic example in glsl language.

regards,

Paulo

Indeed, there is no GL_COMPUTE_SHADER in the Compile function of vtkShader. If I remember well VTK use openGL version 3.2. If you want to create a compute shader, you must compile it yourself, as well as call glComputeDispatch by hand

This is the method to use a user custom shader, but this won’t work in case of a GL_COMPUTE_SHADER (introduced in OpenGL version 4.3). This seems to work only for vertex and fragment shader

1 Like

thanks for the reply, I know this. You can also find some shader-related examples here, but there are no compute shader-related examples.
https://lorensen.github.io/VTKExamples/site/Cxx/#shaders

thanks for the reply.Yes, vtkShader does not include GL_COMPUTE_SHADER. I myself use vtk9.0.0 compiled by mingw4.8.2, and then I use the GetOpenGLVersion method of vtkWin32OpenGLRenderWindow to get the opengl version 4.4. When I compiled vtk9.0.0, I didn’t find a way to set the opengl version. . I will try the way you said,thank you.