3D Trails using GLSL mat

Hi
I’m trying to make a 3D trail effect, where a point moving through space leaves a ‘Chinese ribbon’ trail that follows behind. Doing this with chops and sops is pretty easy, but slow. So I’m attempting it with glsl, and it’s working, but the alignment is off.

3DtrailFail.jpg

The basic idea is to displace the verts with a top(chopTo) from the position trail of a moving object.
geoComp > object chop > trail chop > chopToTop > glslMat
Effectively the position trail is converted from xyz to rgb, and
Inside the vertex shader of the glslMat, the vertices are displaced by sampling the the top.
I can’t get the alignment to work out, and I can’t tell if I have a parenting issue, or am doing something wrong with my vector math.

If you look inside the vertex shader, and uncomment line 83, you can see the geometry without displacement. Its parented, and follows the source object, but not its source vertex.
I’ve banged my head on this for a bit too long, and wondering if any shadery gurus might know how to make this work.

thanks
Thomas
3DtailsA.10.toe (17 KB)

I think you want to set your chopto2 to RGB mode rather than R mode. That way you can sample an XYZ in one sample.

Also, as long as your trail is of a fixed length, I think it’s more practical to do trails with only a vertex shader, not a geometry shader. You should start with a Grid, and then with a point SOP add an attribute with the python expression me.inputPoint.index and name ID. Then do a triangle strip SOP to help the renderer a little. Then in your vertex shader, declare “in float ID” and use that to determine the lookup coordinate.

Personally I find it really convenient and easier to debug when baking attributes into SOPs, as long as the situation allows it.