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

Basic GPU stroke rendering with support for caps and joins #408

Merged
merged 12 commits into from
Nov 14, 2023

Commits on Nov 8, 2023

  1. Shitty offset curves for GPU stroke scaffolding

    Implemented a stroking scheme in the flatten stage in which every
    flattened line segment gets offset along the curve normal by the line
    width. The line vertices are offset _after_ subdivision and does not
    try to accurately estimate subdivisions for the offset curve.
    
    Cusps are not detected and are prone to failure. Regions with high
    curvature (especially around self-intersections) are handled by simply
    boosting the subdivision count using the curve offset which is not
    correct but avoids awfully missing samples when the tolerance is set too
    low.
    
    This is intended as a placeholder but is the first step towards
    implementing correct strokes without optimizing for performance.
    armansito committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    e2f63bd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f72a066 View commit details
    Browse the repository at this point in the history
  3. [encoding] Implement stroke cap marker segment encoding

    - Implemented the stroke cap marker segment encoding scheme outlined in
      #303. The proposed scheme has been slightly modified such that instead
      of an open/closed bit, the segment is encoded as a lineto or quadto
      to distinguish between the different states.
    
      Encoding the marker segment as a quad to for open segments also
      handles a limitation with only using linetos: for an open path, the
      marker must encode both the start tangent and the coordinates of the
      first control point to correctly position a start cap. Encoding these
      as 4 f32s requires an implicit moveto before the lineto which must
      terminate the preceding subpath.
    
      Encoding this as a quadto preserves the invariant that every stroked
      subpath only contains one segment with the SUBPATH_END_BIT set to 1,
      which now serves as the stroke cap marker. For a closed path, a lineto
      is sufficient since the preceding coordinate (from the lineto encoded
      for a "closepath" verb) must already equal the subpath's first control
      point.
    
    - Shitty stroking continues to work by detecting and ignoring the
      stroke cap marker.
    armansito committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    08fc286 View commit details
    Browse the repository at this point in the history
  4. Update caps and joins to use the new stroke cap marker encoding

    The flatten stage now makes use of the stroke cap marker encoding scheme
    to draw caps and joins at the right locations. At this stage only the
    butt cap and bevel join styles are supported.
    armansito committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    73dd128 View commit details
    Browse the repository at this point in the history
  5. [encoding] Eliminate zero-length start segments

    Make sure that a path start segment has a tangent that has a non-zero
    length.
    armansito committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    13810b8 View commit details
    Browse the repository at this point in the history
  6. Update closed stroke tests

    - Add versions of the cubics without co-incident start and end points
    - Reposition the closed paths so they fit within the view
    armansito committed Nov 8, 2023
    Configuration menu
    Copy the full SHA
    deba7c8 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    83359c5 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    1f5a93d View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    24681fa View commit details
    Browse the repository at this point in the history

Commits on Nov 10, 2023

  1. [flatten] Settle on a consistent vector normalization scheme

    Make it so that tangent vectors are NOT normalized and normals
    are normalized. Vector helpers that derive normals from tangents now
    always return normalized vectors.
    
    This keeps things internally consistent.
    armansito committed Nov 10, 2023
    Configuration menu
    Copy the full SHA
    3df413a View commit details
    Browse the repository at this point in the history

Commits on Nov 13, 2023

  1. Address review comments

    armansito committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    eded0a1 View commit details
    Browse the repository at this point in the history
  2. Style and comment fixes in the WGSL

    * Fix the phrasing in a comment regarding subdivision count
    * Use the vec4f and vec2f predeclared aliases for vec4<f32> and vec2<f32>
      in `flatten`. I've been consistent with this style for new code in
      this shader and I may make the other shaders use the alises in a
      follow up since it's more concise.
    armansito committed Nov 13, 2023
    Configuration menu
    Copy the full SHA
    7a122b6 View commit details
    Browse the repository at this point in the history