Hacker News new | ask | show | jobs
by themulticaster 1257 days ago
Hey Raph, hoping you might see this: Almost all (Rust) game engines seem to focus entirely on sprites (or more generally, texture-based primitives) for rendering. I've been experimenting with a toy game project based heavily around more complex 2D primitives [1], such as splines or Bézier curves that might benefit from some vertex-based shader shenanigans [2]. But apparently this is something 2D game engines just don't support. Since you have a lot of experience with curves, Rust and GPUs I was wondering if you can think of specific reasons this path seems to be unsupported?

[1] My goal is to implement realistic train track geometries, including transition curves, using Euler spirals or perhaps a simpler curve.

[2] For example, I'd like to try tessellating curves via shaders as required, based on zoom level etc.

1 comments

I would say the most likely reason is that 2D graphics is just plain hard. Jasper's classic essay[1] goes into more detail.

That said, I'd really love to see more stuff along the lines of what you describe. I think Vello could render, for example, something that visually looks like Mini Metro or Mini Motorways. I also of course would be a massive fan of using Euler spirals - the only curve that's truly, really simpler is quadratic Béziers, and making those look good in your application would be hard. I'm about to do a lot of Euler spiral math on GPU as part of the stroke rework, which you may find interesting.

Strokes are easier for GPUs than fills, because you don't have to worry about the winding number issues (non-convex paths, paths with holes, etc). There are two recent papers, Polar Stroking[2] and Converting stroked primitives to filled primitives[3].

Also check out Freya Holmér's excellent Shapes library[4] (easily integrated with Unity).

Tesselating curves via shaders is the future (through mesh shaders in particular), and I've got a colleague working on that, but portable infrastructure seems to me just as thorny a problem as compute. I am very biased, but if it were me I'd try to render the 2D stuff with a 2D renderer like Vello.

Best of luck with your project, and I'd be interested in following the progress. Feel free to stop by the Zulip[5] and ask such questions there, as well.

[1]: https://blog.mecheye.net/2019/05/why-is-2d-graphics-is-harde...

[2]: https://arxiv.org/abs/2007.00308

[3]: http://w3.impa.br/~diego/projects/Neh20/

[4]: https://assetstore.unity.com/packages/tools/particles-effect...

[5]: https://xi.zulipchat.com/#narrow/stream/197075-gpu