Papers
Topics
Authors
Recent
2000 character limit reached

GPU-friendly Stroke Expansion (2405.00127v2)

Published 30 Apr 2024 in cs.GR

Abstract: Vector graphics includes both filled and stroked paths as the main primitives. While there are many techniques for rendering filled paths on GPU, stroked paths have proved more elusive. This paper presents a technique for performing stroke expansion, namely the generation of the outline representing the stroke of the given input path. Stroke expansion is a global problem, with challenging constraints on continuity and correctness. Nonetheless, we implement it using a fully parallel algorithm suitable for execution in a GPU compute shader, with minimal preprocessing. The output of our method can be either line or circular arc segments, both of which are well suited to GPU rendering, and the number of segments is minimal. We introduce several novel techniques, including an encoding of vector graphics primitives suitable for parallel processing, and an Euler spiral based method for computing approximations to parallel curves and evolutes.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (23)
  1. 2021. MotionMark 1.2. https://browserbench.org/MotionMark1.2/about.html
  2. World Wide Web Consortium 2024. WebGPU. World Wide Web Consortium. https://www.w3.org/TR/webgpu
  3. Dale Connor and Lilia Krivodonova. 2014. Interpolation of two-dimensional curves with Euler spirals. J. Comput. Appl. Math. 261 (2014), 320–332. https://doi.org/10.1016/j.cam.2013.11.009
  4. Scalable Vector Graphics (SVG 2) Candidate Recommendation. World Wide Web Consortium. https://www.w3.org/TR/SVG2/painting.html#StrokeShape
  5. The gfx-rs authors. 2024. gfx-rs/wgpu. https://github.com/gfx-rs/wgpu
  6. Ron Goldman. 2003. Chapter 5 - Bezier Approximation and Pascal’s Triangle. In Pyramid Algorithms, Ron Goldman (Ed.). Morgan Kaufmann, San Francisco, 187–306. https://doi.org/10.1016/B978-155860354-7/50006-4
  7. Google. 2024. Skia. https://skia.org
  8. Rive Inc. 2024. Rive Renderer. https://github.com/rive-app/rive-renderer
  9. Mark J. Kilgard. 2020. Polar Stroking: New Theory and Methods for Stroking Paths. ACM Trans. Graph. 39, 4, Article 145 (Aug. 2020), 15 pages. https://doi.org/10.1145/3386569.3392458
  10. Euler Spiral for Shape Completion. International Journal of Computer Vision 54, 1 (01 Aug 2003), 159–182. https://doi.org/10.1023/A:1023713602895
  11. Georg Maier. 2014. Optimal arc spline approximation. Computer Aided Geometric Design 31, 5 (2014), 211–226. https://doi.org/10.1016/j.cagd.2014.02.011
  12. D. S. Meek and D. J. Walton. 2004. An arc spline approximation to a clothoid. J. Comput. Appl. Math. 170, 1 (2004), 59–77. https://doi.org/10.1016/j.cam.2003.12.038
  13. Smita Narayan. 2014. Approximating Cornu spirals by arc splines. J. Comput. Appl. Math. 255, 1 (2014). https://doi.org/10.1016/j.cam.2013.06.038
  14. Diego Nehab. 2020. Converting Stroked Primitives to Filled Primitives. ACM Trans. Graph. 39, 4, Article 137 (Aug. 2020), 17 pages. https://doi.org/10.1145/3386569.3392392
  15. Taweechai Nuntawisuttiwong and Natasha Dejdumrong. 2021. An Approximation of Bézier Curves by a Sequence of Circular Arcs. Information Technology and Control 50, 2 (2021). https://doi.org/10.5755/j01.itc.50.2.25178
  16. I. F. D. Oliveira and R. H. C. Takahashi. 2020. An Enhancement of the Bisection Method Average Performance Preserving Minmax Optimality. ACM Trans. Math. Softw. 47, 1, Article 5 (Dec. 2020), 24 pages. https://doi.org/10.1145/3423597
  17. Amar Patel and Tex Riddell. 2024. D3D12 Work Graphs. DirectX Developer Blog. https://devblogs.microsoft.com/directx/d3d12-work-graphs/
  18. Ulrich Reif and Andreas Weinmann. 2021. Clothoid fitting and geometric Hermite subdivision. Advances in Computational Mathematics 47, 50 (26 June 2021). https://doi.org/10.1007/s10444-021-09876-5
  19. W. Tiller and E. G. Hanson. 1984. Offsets of two-dimensional profiles. IEEE Computer Graphics and Applications 4, 9 (Sept. 1984), 36–46.
  20. D. J. Walton and D. S. Meek. 2009. G1 interpolation with a single Cornu spiral segment. J. Comput. Appl. Math. 223, 1 (2009), 86–96. https://doi.org/10.1016/j.cam.2007.12.022
  21. Heinrich Wieleitner. 1907. Die Parallelkurve der Klothoide. Archiv der Mathematik und Physik 11 (1907), 373–375.
  22. Norimasa Yoshida and Takafumi Saito. 2012. The Evolutes of Log-Aesthetic Planar Curves and the Drawable Boundaries of the Curve Segments. Computer-Aided Design and Applications 9, 5 (2012), 721–731. https://doi.org/10.3722/cadaps.2012.721-731
  23. Fabian Yzerman. 2020. Fast approaches to simplify and offset Bézier curves within specified error limits. https://blend2d.com/research/simplify_and_offset_bezier_curves.pdf

Summary

  • The paper's main contribution is a novel GPU-friendly stroke expansion algorithm that leverages parallel computation for real-time rendering.
  • The authors employ Euler spiral approximations and optimized subdivision density to accurately compute offset curves for vector strokes.
  • Results show significant performance gains and reduced memory bandwidth usage, validating the method's effectiveness over traditional CPU approaches.

GPU-friendly Stroke Expansion: A Technical Overview

The research paper “GPU-friendly Stroke Expansion” by Raph Levien and Arman Uguray introduces a novel approach to stroke expansion that is particularly amenable to GPU implementation. In vector graphics, strokes and fills are fundamental primitives; however, rendering strokes efficiently on the GPU has presented notable challenges, particularly with respect to continuity and correctness. This paper addresses these challenges by proposing an algorithm that is suitable for execution in a GPU compute shader, emphasizing parallel processing and minimal preprocessing.

Key Contributions and Techniques

The paper’s primary contribution is an efficient algorithm for stroke expansion, generating outlines of stroked paths using parallel computation. The authors introduce several innovative techniques to achieve this:

  1. Encoding Vector Primitives: The authors present an encoding method for vector graphics primitives that optimizes the data for parallel processing on GPUs.
  2. Euler Spiral Approximation: The method utilizes Euler spirals to compute approximations of parallel curves and evolutes, facilitating efficient calculation of offset curves.
  3. Parallel Curve Handling: The paper discusses handling both lines and circular arc segments as output, which reduces the segment count and aligns with GPU rendering capabilities.
  4. Subdivision Density Integral: An essential component of the method is the precise handling of subdivision density for flattening curves, which ensures that the segments approximate the stroke path within a given tolerance.
  5. Error Metrics: The paper proposes an error metric to predict approximation errors, allowing the avoidance of costly iterative error measurements.

Results and Performance

The algorithm is implemented in GPU compute shaders and shows significant performance advantages over CPU-only methods, demonstrating dramatic speed improvements. The results are validated using a suite of test cases, showing that the GPU implementation can handle a substantial number of input path segments at real-time rates while maintaining visual fidelity.

The use of circular arcs, in particular, reduces the number of output segments significantly when compared to line-based approximation, making the algorithm not only faster but also reducing memory bandwidth consumption.

Practical and Theoretical Implications

Practically, the research opens pathways for more efficient rendering engines that leverage the GPU for both strokes and fills, broadening the applicability of GPU-accelerated vector graphics across various platforms and devices. Theoretically, the paper enriches the existing literature on GPU-friendly algorithms, providing a model for how complex geometric problems can be adapted for fully parallel computation.

Future Developments

While the proposed method achieves weak correctness, the authors suggest that future developments could target strong correctness by implementing evolutes and inner join contours, further enhancing the accuracy of stroke rendering. Additionally, addressing GPU memory management and load balancing could yield further improvements in performance and scalability.

In conclusion, the paper provides a comprehensive and technically robust approach to a longstanding problem in computer graphics, laying a foundation for future advancements in GPU-accelerated rendering techniques.

Dice Question Streamline Icon: https://streamlinehq.com

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Lightbulb Streamline Icon: https://streamlinehq.com

Continue Learning

We haven't generated follow-up questions for this paper yet.

List To Do Tasks Checklist Streamline Icon: https://streamlinehq.com

Collections

Sign up for free to add this paper to one or more collections.

X Twitter Logo Streamline Icon: https://streamlinehq.com

Tweets

This paper has been mentioned in 6 tweets and received 5 likes.

Upgrade to Pro to view all of the tweets about this paper:

Youtube Logo Streamline Icon: https://streamlinehq.com

HackerNews

  1. GPU-Friendly Stroke Expansion (175 points, 39 comments)
  2. GPU-Friendly Stroke Expansion (2 points, 0 comments)
Reddit Logo Streamline Icon: https://streamlinehq.com

Reddit

  1. GPU-Friendly Stroke Expansion (1 point, 1 comment)