# Geometry Shader Implementation

**URL:** https://discourse.vtk.org/t/geometry-shader-implementation/1189
**Category:** Support
**Created:** [June 21, 2019, 8:42am UTC](https://discourse.vtk.org/t/geometry-shader-implementation/1189 "2019-06-21T08:42:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Tharun](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/67e7ee/32.png) [@Tharun](https://discourse.vtk.org/u/Tharun)
#### Post date: [June 21, 2019, 8:42am UTC](https://discourse.vtk.org/t/geometry-shader-implementation/1189/1 "2019-06-21T08:42:11Z")

</div>

Can someone please guide me on how to inject Geometry Shader Code?

---

<div class="post-metadata">

### Author: ![Michael](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael/32/16_2.png) [@Michael](https://discourse.vtk.org/u/Michael)
#### Post date: [June 21, 2019, 11:17am UTC](https://discourse.vtk.org/t/geometry-shader-implementation/1189/2 "2019-06-21T11:17:30Z")

</div>

Hi,  
In VTK 8: [vtkOpenGLPolyDataMapper::AddShaderReplacement](https://vtk.org/doc/nightly/html/classvtkOpenGLPolyDataMapper.html#a0ac956a17bc822a07b7d92625b293e2e)  
In VTK 9 (and current master): [vtkShaderProperty::AddGeometryShaderReplacement](https://vtk.org/doc/nightly/html/classvtkShaderProperty.html#a6e2e52383177eb038802c2b681197c89)

---

<div class="post-metadata">

### Author: ![dmreagan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dmreagan/32/7489_2.png) [@dmreagan](https://discourse.vtk.org/u/dmreagan)
#### Post date: [July 1, 2019, 5:01pm UTC](https://discourse.vtk.org/t/geometry-shader-implementation/1189/3 "2019-07-01T17:01:43Z")

</div>

I found that `AddShaderReplacement` didn’t work from Python for geometry shaders, so I have used [vtkOpenGLPolyDataMapper::SetGeometryShaderCode](https://vtk.org/doc/nightly/html/classvtkOpenGLPolyDataMapper.html#acce2e848fee2cd1d0513c75076702893).

You can see a simple example [here](https://github.com/dmreagan/fury-shaders/blob/master/geometry.py) that takes in a cube and replaces each vertex with a pyramid. The example uses the [FURY](http://fury.gl/) library, but the shader part is raw VTK.
