Hacker News new | ask | show | jobs
by w0utert 2635 days ago
Very interesting and useful, but when I read the title I was hoping it would be something different.

I would love to find some kind of stripped-down vector graphics engine that is fully geared towards real-time rendering of path-based graphics for games. For example to write retro-style games that use 2D vector graphics instead of textured quads. I've been writing a simple game that uses this graphics style, and so far I've been simply using pre-rendered textures for sprites. Being able to directly render these things by composing vector-based layers would allow all kinds of interesting effects and image quality improvements, e.g. seamless scaling morphing, etc. Obviously this would be way, way slower than emulating these things using bitmap textures and/or SDF's for scaling, but for the simple graphics my game is using that should probably be fine, even on mid-range hardware there is plenty of frame time I could dedicate to vector rendering and still hit at least 30fps.

4 comments

There are a few of those out there. Nanovg seems to be the one that fits your requirements most closely. If you're into Rust, lyon (plus something like gfx-rs) is another choice.

It's also worth noting that the HTML canvas implementations in most browsers is also not too bad for performance. Quartz is also really fast, but Apple made it really easy to accidentally use a slow rendering path (especially for bitmap operations)

I have had great success using the ideas presented here (http://m1el.github.io/woscope-how/index.html) for simulation of traditional vector graphic screens. It is very fast and easily modified to allow for intensity modulation as well.
I really enjoyed your demo. Thank you.
Just to clarify. This was not my work. I have just used the ideas presented therein for my own works and found them easy to adapt and improve upon.
Pathfinder fits the description: https://github.com/pcwalton/pathfinder

This AR demo on MagicLeap shows the potential: https://twitter.com/asajeffrey/status/1106667615622180864

GPUs really just aren't designed for 2D vector graphics. There is a litany of approaches (three separate ones from pcwalton's Pathfinder R&D alone), and all of them have various issues and tradeoffs. If your GPU has enough power for one of the more advanced approaches like Slug or Pathfinder1's compute shaders, then your CPU likely has enough for Blend2D and the bandwidth for the resulting texture upload.

Pathfinder3 looks promising, but comes with its own tradeoffs. It's an open area of research.

When listing approaches, people should look at Skia Compute[0]. While it is true that traditional GPU's are not a super-great match for 2D graphics, modern GPU's are becoming more and more CPU-like, just with more parallelism. I haven't done careful quantitative evaluation of compute myself, but don't feel that any understanding of modern 2D graphics performance would be complete without that.

[0]: https://github.com/google/skia/tree/master/src/compute/skc

Wow, I haven't seen this before, thank you for the pointer! This reminds me of some of the work in this 2014 paper which used a compute-based algorithm on the GPU to implement vector textures. And of course the works of GLyphy and PF1. http://w3.impa.br/~diego/projects/GanEtAl14/