# Using GLSL post-process (2D) pixel shader with Slicer

**URL:** <https://discourse.slicer.org/t/using-glsl-post-process-2d-pixel-shader-with-slicer/1789>\
**Category:** Development\
**Created:** [January 9, 2018, 1:47pm UTC](https://discourse.slicer.org/t/using-glsl-post-process-2d-pixel-shader-with-slicer/1789 "2018-01-09T13:47:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdx-john](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@jdx-john](https://discourse.slicer.org/u/jdx-john)\
**Post date:** [January 9, 2018, 1:47pm UTC](https://discourse.slicer.org/t/using-glsl-post-process-2d-pixel-shader-with-slicer/1789/1 "2018-01-09T13:47:19Z")

</div>

_I assume this is a dev rather than user question, that we cannot do it using an extension?_

We have some GLSL shaders used to post-process a textured quad. In our application we use this in conjunction with 3D rendering and vertex/pixel shaders on polygonal models, but this shader is applied after all the transforms and normal rendering - essentially just on the contents of the render buffer applied to a quad and then run several passes.

This means - we think - we can take our shader and apply it to _any_ source image using standard OpenGL. @lassoan has previously told us we can do anything VTK can in Slicer and VTK has shader support but he’s not a shader developer and I’m not a slicer developer so any help figuring out what I can do, and where I “get into” Slicer to do this sort of thing, would be wonderful.  
e.g. how to attach my shader to a render pipeline or to a view, how to bind any arguments/parameters it needs. We’re in the situation we have shader/OpenGL developers and Slicer developers and a VTK developer but no cross-over between them for this specific case!

---

<div class="post-metadata">

**Author:** ![Davide\_Punzo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide_punzo/32/66104_2.png) [@Davide\_Punzo](https://discourse.slicer.org/u/Davide_Punzo)\
**Post date:** [January 9, 2018, 3:48pm UTC](https://discourse.slicer.org/t/using-glsl-post-process-2d-pixel-shader-with-slicer/1789/2 "2018-01-09T15:48:34Z")

</div>

I am not sure that it will help, there is this VTK class:

> <https://github.com/Kitware/VTK/blob/master/Rendering/OpenGL2/vtkOpenGLImageAlgorithmHelper.h>

  
in which you can provide your shader and input data (as a vtkImageData) and get the output data (again as a vtkImageData).

Instead, if you’d like to “add” your shader to the regular VTK rendering pipeline, you may try to ask @pieper. He worked on something similar.

---

<div class="post-metadata">

**Author:** ![Davide\_Punzo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide_punzo/32/66104_2.png) [@Davide\_Punzo](https://discourse.slicer.org/u/Davide_Punzo)\
**Post date:** [January 9, 2018, 3:54pm UTC](https://discourse.slicer.org/t/using-glsl-post-process-2d-pixel-shader-with-slicer/1789/3 "2018-01-09T15:54:59Z")

</div>

see also this link: [https://www.vtk.org/Wiki/Shaders\_In\_VTK](https://www.vtk.org/Wiki/Shaders_In_VTK)

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [January 10, 2018, 12:53pm UTC](https://discourse.slicer.org/t/using-glsl-post-process-2d-pixel-shader-with-slicer/1789/4 "2018-01-10T12:53:57Z")

</div>

Hi,

This project shows an example of customized rendering shader. See [https://github.com/KitwareMedical/vtkColorCodedDepthVolume](https://github.com/KitwareMedical/vtkColorCodedDepthVolume)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 10, 2018, 10:05pm UTC](https://discourse.slicer.org/t/using-glsl-post-process-2d-pixel-shader-with-slicer/1789/5 "2018-01-10T22:05:32Z")

</div>

Here’s the other GLSL code @Davide_Punzo mentioned. It’s less coupled to the vtk rendering process so it can make it simpler to do generic algorithms. At some point I plan to revisit this and see how it compares to the shader options recently added to VTK core and see if it’s still needed.

> **[GitHub - pieper/CommonGL: Experiments in GLSL shading for Slicer and other...](https://github.com/pieper/CommonGL)**
>
> Experiments in GLSL shading for Slicer and other environments - GitHub - pieper/CommonGL: Experiments in GLSL shading for Slicer and other environments
