abey79 / vsvg

Fast and portable tools for plotter users
http://whisk.rs
MIT License
107 stars 12 forks source link

Next gen renderer #9

Open abey79 opened 1 year ago

abey79 commented 1 year ago

Lots of thinking going on on what should be the next gen renderer for vpype/vsketch.

Main issue: geometry shaders are basically bad, which makes the vpype 1.x approach problematic. For example, WGSL don't support them.

I current see the following approaches.

1) CPU-based non-overlapping triangulation

This basically re-implements vpype 1's approach, i.e. generating non-overlapping triangles covering the fat line and using SDF for round ending/joins + AA rendering.

I've made an initial implementation in 8274167f1175bbba7085c9fbd8897f7def4cadb0 and following.

Issues:

1b) GPU compute of the same

No idea how good an idea this would be.

2) Instanced drawing and SDF-based overlap control

This needs to be prototyped. The idea is to have a simple 2-triangle primitive instanced for all segment point pairs, and address over-draw at the SDF level. This probably requires precomputing the miter vectors, to be used as half-plan separator for the SDF.

Advantages:

abey79 commented 1 year ago

vsvg-viewer now has GPU-based implementation for (2) working pretty well :tada: