Success with Geometry Shaders

So finally, after playing around a bit with Geometry Shaders and having brainstormed a lot, we got some success in Geometry Shaders and this can be considered as a good accomplishment in this GSoC project. With the help of vtk.SetGeometryShaderCode now I am able to inject my custom shader and able to amplify points.

As a first step towards achieving custom visualization, I attempted to amplify a point into lines as given in the example here. I was able to achieve this but was unable to color the points as per my wish. This is where David came to my rescue and helped me out with coloring the points in a GS.

The trick here is to add line_strip as the outputĀ of the Geometry Shader. In case we want triangle strips, we have to replace it with triangle_strip. On the first go, I obtained a visualization as shown below. The complete code is available here.

Next, after having checking basic line rendering, its time to try out with 2-D shapes such as triangles and squares. So replacing line_strip with triangle_strip and make necessary changes, we obtain a beautiful representation of a pentagon each on the four positions of the screen as shown below. The complete code for this part of the project can be seen here.

The aim now is to display a sphere built using triangles as done previously using vertex and fragment shaders. As of now, we are able to see shapes on the screen but unfortunately, we hit vertex limitation as we can not use too many vertices in a single geometry shader. For my system with Windows and anaconda environment, we can get only 256 amplified vertices per base vertex. For David, this number was less than 256. So, we may not be able to use Geometry Shader to always render complicated shapes but this is surely interesting and can be of great use.

thechargedneutron

Leave a Reply

Your email address will not be published. Required fields are marked *