-
Notifications
You must be signed in to change notification settings - Fork 140
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
Fill tessellation and keeping track of vertex colour attributes for post-tessellation interpolation #488
Comments
This adds a path drawing API that is a vastly more flexible and correct version of the existing polyline and polygon APIs. Allows for tessellating any given path with either lyon's FillTessellator or the StrokeTessellator, with builder methods provided for all the available options. Colored vertices are currently only supported for stroke tessellation as I'm currently unsure how to retain the color attributes for vertices during the fill tessellation process (see nical/lyon#488).
Hi! This is by far the most requested feature and it's a little tricky because the fill tessellator has to insert new vertices (when there are self-intersections) and sometimes merges vertices that are at the same position. Indeed the tessellator consumes the entire iterator before tessellating, because it has to sort all points from top to bottom (and from left to right for points with the same y coordinate). To make things worse, points are internally converted to 16.16 fixed-point numbers and the position you are given in I'm making good progress on the new tessellator, but it isn't usable yet. I'm hoping to publish it towards the end of summer. Let me know if this kind of incomplete solution would be valuable to you in the mean time. |
Thanks a lot for the detailed response!
No worries at all @nical! We can absolutely live with the existing |
This adds a path drawing API that is a vastly more flexible and correct version of the existing polyline and polygon APIs. Allows for tessellating any given path with either lyon's FillTessellator or the StrokeTessellator, with builder methods provided for all the available options. Colored vertices are currently only supported for stroke tessellation as I'm currently unsure how to retain the color attributes for vertices during the fill tessellation process (see nical/lyon#488).
The new tessellator in the master branch is now able to give information about which endpoint(s) of the input path a vertex comes from, or where in between several endpoints the vertex comes from if it was created as a result of self-intersection or curve flattening. The new tessellator also has the ability to associate slices of floats to each endpoint and automatically interpolate them when needed, to simplify common use cases like per-vertex color or variable line width. It took a while longer than I planned, sorry! Release coming in a few days. |
Hi @nical! I've been switching nannou's 2D tessellation over to lyon and it's been a joy to use! Thank you so much for all your work :)
One thing I'm currently struggling with is how to keep colour data associated with vertices during the fill tessellation process. E.g. Nannou provides an API for drawing a coloured polygon by submitting an iterator of coloured points, where the surface colour is linearly interpolated between each of the vertices (we get the interpolation "for free" in the fragment shader). The
FillTessellator::tessellate_path
method expects an iterator yieldingPathEvent
s, which I can produce using thelyon::path::iterator::FromPolyline
iterator adaptor around the user-submitted vertices, however in order to do so I have to drop the vertices' colour attribute and instead yield lyon points.I've been able to work around this during stroke tessellation by using a custom
GeometryBuilder
to rebuild the colour types by retrieving the colour from aCell<Color>
that gets set each timenext
is called on the user-submitted vertex iterator, however I think I'm just getting lucky in this case as it seems that lyon'sStrokeTessellator
just happens to generate all vertices nearest each user submitted vertex while it takes them from the iterator. TheFillTessellator
on the other hand seems to consume all vertices before callingGeometryBuilder::add_vertex
so my hack doesn't work in this case.Any advice greatly appreciated! And thanks again for all your invaluable research and hard work :)
The text was updated successfully, but these errors were encountered: