[VTK] Render to target/texture?


(Adam Rankin) #1

Hello all,

Does anyone have any experience with rendering to a texture instead of an on-screen window? For the life of me I cannot find a VTK example that does this.

Links to examples or a high-level description should be more than enough for me to sort this out…

Edit: typo


(Steve Pieper) #2

Hi @adamrankin -

Yes, GLSL rendering to/from 3D texture is something I’ve been working on for a while. See this commit for info:

https://github.com/Slicer/Slicer/commit/16a4878de6f17f097618cfb4472cb209538bf82c

@Sunderlandkyl and I have been working on this in the context of fractional segmentation effects (e.g. for soft edged paint brushes).

Everything was working pretty well in Slicer 4.8, but once we switched to the OpenGL2 backend some OpenGL runtime errors have popped up and so some debugging is needed. Would be great to work with you on this!

I should mention that I have been playing around with the same functionality using WebGL2 and it works great there. My long-term goal is to have libraries of GLSL code that can work well in either context.

Of course we also want this to be native in VTK and integrate smoothly with the GPU volume rendering. Several of us worked on customizing VTK’s shaders at the last Las Palmas Project Week. At this point the vtkOpenGLTextureImage and vtkOpenGLShaderComputation code in Slicer’s vtkAddons provides features not available (yet) in regular VTK.

-Steve