GhGL Shader for Two Colored Polyline


I’m trying to make a shader which draws a line in the viewport. It’s fed points and it draws straight line segments between the points. Not surprisingly, that works no problem! Now I want to feed the shader two lists. The same set of points. And a new list which is either 0s or 1s. If the value is 0 I want to draw with one color. If the value is 1 I want to draw with the other color. Should be simple. But it doesn’t work and I’m not sure what I’m doing wrong. Right now it always draws with color 0.

I’ve attached a simple GH definition with the shader defined. If anyone can offer suggestions I’d appreciate it.

This is for CNC work. The traverses between toolpaths would be one color and the toolpaths themselves would be another color. In this trivial example there are 3 rectangles. Those should be one color. The lines between them another.

Mark (8.2 KB)

Hi Mark,
There was a bug in GhGL for dealing with lists of integer values. I just published a new version of GhGL (7.2.0) with a fix for this bug that you should be able to install with the PackageManager.

I also adjusted your glsl code to use uniforms for the input colors as that is what you should be using for inputs that are shared across all of the vertices being input to the shaders. Attached is an updated version of the definition. Let me know if you have any questions. (14.0 KB)

Thanks very much, Steve. It works nicely :grinning: The PackageManager is very convenient.


1 Like