July 2nd, 2024

GPU-Friendly Stroke Expansion

The paper introduces a GPU-friendly technique for stroke expansion in vector graphics, optimizing GPU rendering with parallel algorithms and minimal preprocessing. It addresses efficient rendering of stroked paths, enhancing performance in vector graphics.

Read original articleLink Icon
GPU-Friendly Stroke Expansion

The paper titled "GPU-friendly Stroke Expansion" by Raph Levien and Arman Uguray introduces a technique for stroke expansion in vector graphics, specifically focusing on generating outlines representing the stroke of input paths. The method is designed for GPU execution using a fully parallel algorithm, suitable for compute shaders with minimal preprocessing. The output can consist of line or circular arc segments, optimized for GPU rendering with a minimal number of segments. The paper presents innovative approaches, such as encoding vector graphics primitives for parallel processing and using an Euler spiral-based method for approximating parallel curves and evolutes. This work addresses the challenge of rendering stroked paths efficiently on GPUs, offering solutions for continuity and correctness constraints. The approach aims to enhance the performance of rendering stroked paths in vector graphics applications.

Related

Eight million pixels and counting: improving texture atlas allocation in Firefox (2021)

Eight million pixels and counting: improving texture atlas allocation in Firefox (2021)

Improving texture atlas allocation in WebRender with the guillotiere crate reduces texture memory usage. The guillotine algorithm was replaced due to fragmentation issues, leading to a more efficient allocator. Visualizing the atlas in SVG aids debugging. Rust's simplicity and Cargo fuzz testing are praised for code development and robustness. Enhancements in draw call batching and texture upload aim to boost performance on low-end Intel GPUs by optimizing texture atlases.

SVG: The Good, the Bad, and the Ugly (2021)

SVG: The Good, the Bad, and the Ugly (2021)

SVG, scalable vector graphics, is a versatile format for web design, supporting various graphic elements like paths, shapes, text, and animations. Despite its power, its complexity and extensive specifications can be challenging for users.

Homegrown Rendering with Rust

Homegrown Rendering with Rust

Embark Studios develops a creative platform for user-generated content, emphasizing gameplay over graphics. They leverage Rust for 3D rendering, introducing the experimental "kajiya" renderer for learning purposes. The team aims to simplify rendering for user-generated content, utilizing Vulkan API and Rust's versatility for GPU programming. They seek to enhance Rust's ecosystem for GPU programming.

Desperately Seeking Squircles

Desperately Seeking Squircles

An engineer aims to incorporate Apple's 'squircle' shape into Figma, navigating mathematical complexities with superellipse formulas and Bézier curves. Challenges in mirroring and transitioning the shape prompt a proposed smoothing scheme for versatile designs. Differential geometry aids in mathematically analyzing the squircle's perimeter, showcasing the intricate process of digital design translation.

CSS Surprise Manga Lines

CSS Surprise Manga Lines

The article explains creating a manga-style surprise effect with CSS, focusing on replicating character facial lines. It suggests using GIF overlays for better performance than CSS animations. Published on July 2, 2024.

Link Icon 17 comments
By @djoldman - 5 months
Gotta like:

> 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.

It's hard but we did it anyway.

By @a_e_k - 5 months
If you're interested in this, let me also plug the High Performance Graphics 2024 conference where this paper was accepted and will be presented at the end of the month. It'll be co-located with SIGGRAPH 2024 in Denver, CO. Come for HPG, stay for SIGGRAPH.

Here's the full program: https://www.highperformancegraphics.org/2024/program/

(Disclosure: I'm on the HPG conference committee.)

By @DLoupe - 5 months
Oops, he did it again. Congrats Raph, and thanks - your work and your writing have been an inspiration to me for my entire career (~25 years).
By @enriquto - 5 months
Happy to see the neverending fruits of using Euler spirals in place of Béziers. Very few people can boast of such influential phd work.
By @amelius - 5 months
I'd like to see calligraphic paths. I.e., you have some primitive like an ellipse that you move along a path while keeping its orientation fixed wrt the coordinate system.

This is something that Adobe Illustrator could do 20 years ago, but is still not possible in Inkscape. I.e., you select a path, set a calligraphic pen on it, and then optionally covert the stroke to its outline path.

By @montroser - 5 months
Stroke expansion is one of those things that initially seems obvious and intuitive, but then turns out to be wildly complex once you embark upon handling all of the many edge cases.
By @robinduckett - 5 months
Only last week I was trying to find out how to draw a dashed stroke on a path without needing a separate draw call for each dashed segment. I hope someone makes a library that uses this technique, it may be slightly beyond my abilities to implement myself.
By @mehmetoguzderin - 5 months
Fascinating, to say the least, especially considering the execution time in comparison to the best CPU result. I might be skimming too fast, but are there also CPU timings for stress test scenes in the paper, including mmark, etc.?
By @Klaster_1 - 5 months
I heard that text rendering on GPU is hard, can the proposed approach pave the road to a reliable and widespread solution?
By @posix86 - 5 months
Looks interesting! Another interesting paper on this subject is 1. They seem to have a different approach; the one I reference uses a quadratic bezier approximation that is fast for random access graphics such as fragment shaders. This is very useful for having screen space constant width shapes in 2- or 3d space, skimming the paper that appears to require much more preprocessing.

1: https://hhoppe.com/proj/ravg/

By @azeirah - 5 months
If this is novel and as reliable as I feel like they're claiming it to be, then this might be really big for svg-rendering in the web, absolutely amazing!
By @aappleby - 5 months
Google Maps does stroke expansion in WebGL 1 vertex/pixel shaders. The vertex shader converts a linear path-segment "instance" into a quad with correctly beveled/extended endpoints, the pixel shader does some normalization and distance-field-esque math (there's no actual distance field texture) to produce analytically antialiased line segments with circular caps.
By @YmiYugy - 5 months
In the comparison it seems like Skia is quite a bit faster on the CPU than your solution, but at the cost of some robustness. Is this actually something that matters for typical applications like web browsers or UI toolkits?
By @martin293 - 5 months
Could anyone please explain what stroke expansion actually is either on high school or math undergrad level?
By @YmiYugy - 5 months
Do you have a rough idea whether doing this on the GPU is worth it on mobile devices with regards to energy consumption? I imagine many typical web and UI toolkit uses of this aren't limited by raw performance.
By @erwinh - 5 months
Does anyone know of ways to expand this towards 3D paths with consistent screen-space stroke width?