Normalizing Polyline texture coordinates

It would appear that the texture coordinates of a polyline are divided equally according to the number of segments, so given a 2 segment polyline, the S coordinate will be: 0, 0.5, 1.
This causes a problem when trying to implement a dashed line.

Here’s an illustration of the issue:
The dash density of the cyan line changes based on segment length.

I want the line to have texture coordinates that correspond to its segment’s length.
So for the same line, with 2 segments, if the first segment is three times the length of the second, the S coordinates should be: 0, 0.75, 1.

The built-in dashed line moves along with the camera, and was rejected by our designer.
Performance is also an issue, so making every segment a separate polyline is not feasible.

I have 2 potential solutions for this, but I’m in need of assistance with implementation.

  1. A custom shader that receives length dependent coordinates in its uniform.
    For this method, I don’t know how to pass an array to the shader.
    One suggestion I’ve seen is passing a 1D texture, but I’m a newbie in GLSL, and don’t know how to assign and retrieve the values.

  2. A custom polyline, where the texture coordinates are assigned based on segment length.
    In this case, I just don’t know where the line is created.
    If someone could direct me to the part of the code where this happens, I’m pretty sure I can make an alternative, or add some variable, that builds the mesh with normalized texture coordinates.

Any help is appreciated.

I will try imbedding the data into the shader code passed to the fabric source.
I saw someone do that for a heatmap shader.

Edit: not working out :confused: