piet-wgpu icon indicating copy to clipboard operation
piet-wgpu copied to clipboard

could you describe your general approach?

Open wtholliday opened this issue 3 years ago • 6 comments

I'm curious :)

I've got a 2D wgpu renderer that might be useful to look at and borrow from: https://github.com/audulus/vger-rs

cheers

wtholliday avatar Mar 17 '22 15:03 wtholliday

For shapes, I’m using Lyon to tress the paths into triangles. For text, I use font kit to draw to pixel map, and quad it.

I checked out your repo the other day and SDF certainly looks really interesting. How does the font rendering looks comparing to “native”?

dzhou121 avatar Mar 17 '22 15:03 dzhou121

Ah cool. Well for the font rendering I'm using fontdue, not the SDF path rendering. I'm using the same atlas texture technique as in nanovg (glyphs are rendered into the atlas as needed, as opposed to making a single atlas for an entire font). Perhaps this is the same as your approach. I think it looks quite good except there are potentially some layout issues with fontdue, and it lacks subpixel AA. I tried using my path renderer for glyphs and it's just too inefficient.

wtholliday avatar Mar 17 '22 18:03 wtholliday

Well for the font rendering I'm using fontdue

How do you render stroked glyphs with fontdue?

UE2020 avatar Mar 23 '22 22:03 UE2020

How do you render stroked glyphs with fontdue?

See here: https://github.com/audulus/vger-rs/blob/abe8274f8cc155a9018f339354ed5ee836c05861/src/glyphs.rs#L35

wtholliday avatar Mar 23 '22 23:03 wtholliday

I tried using my path renderer for glyphs and it's just too inefficient.

I tried that before. Just too many triangles that need to send to GPU.

I'm recently trying swash to do the text rendering which supports subpixel AA and text shaping. The end result seems very good.

dzhou121 avatar Apr 08 '22 19:04 dzhou121

How do you render stroked glyphs with fontdue?

See here: https://github.com/audulus/vger-rs/blob/abe8274f8cc155a9018f339354ed5ee836c05861/src/glyphs.rs#L35

The rasterize function outputs filled text, not stroked text. When I say stroked text, I mean something like this: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeText

UE2020 avatar Apr 13 '22 23:04 UE2020