Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stroke Tessellation: advancement does not give accurate UV coordinates #915

Open
timmb opened this issue Aug 13, 2024 · 1 comment
Open

Comments

@timmb
Copy link
Contributor

timmb commented Aug 13, 2024

I'm trying to get UV coordinates on a tessellated stroke by using the path advancement.

It nearly works, but where there are straight line segments joining other segments with tight angles, the tesselation creates large triangles. The inside and outside parts of the line are different lengths and the UVs end up drifting as we go along the path.

Path showing advancement

This image shows 10 cycles of the normalized advancement along the path.

Wireframe of path
This wireframe shows how the tessellation contributes to this.

For correct UV, I'd want the UV values to be equal along a line normal to the path. This happens in the curved segments because they're tessellated with a lot more triangles.

Some possible ways to resolve this issue would be:

  • As well as advancement, as a property of StrokeVertex, if we could also have the advancement of the nearest point on the path to this vertex (usually this will be the same as advancement, except at some corners)
  • Perhaps easier, but less preferable, would be an option to increase the triangulation of straight line segments in a path.
@nical
Copy link
Owner

nical commented Aug 27, 2024

Hi, yeah that's a bit tricky unfortunately (depending on what you expect the correct behavior to be). Increasing the tessellation of straight lines in a way that distributes the stretching introduced by a sharp turn would look better, but it would still stretch the uvs (it wouldn't look quite right if you draw, say, a road texture along it). and it would not address the same problem happening with two curves meeting at a sharp turn. One might argue that the best behavior should be to only introduce distortion near the join.

In any case I agree that the current behavior is not very good for shapes that aren't smooth.

Unfortunately I am very short on spare time to dedicate to improving the stroke tessellator at the moment. If you or someone else feel adventurous, I'd be happy to review contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants