Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to bevy 0.14, usvg 0.42, and several bug fixes #41

Merged
merged 33 commits into from
Jul 28, 2024

Conversation

StrikeForceZero
Copy link
Contributor

@StrikeForceZero StrikeForceZero commented Jul 18, 2024

I'm dropping this here in case this helps anyone. It still disappointingly fails to render specific svg's with compounded transforms and text doesn't appear to be working.

Knight now renders correctly fixing #37
image

Old Details

image

Text stopped rendering with usvg version >=0.38 (not rendering text for resvg cli)

image

Compounded transforms still broken (working for resvg cli)

image

Renders twinkle (if you fix it by removing the illegal group nodes inside text/tspan or resave in inkscape)
image

Bevy Logo
image

Queen of hearts
image

Averaging of gradients for fallback (instead of showing nothing)
image

@StrikeForceZero
Copy link
Contributor Author

StrikeForceZero commented Jul 19, 2024

So I finally figured out why the transforms were messing with the rendering. Although, it's fixed every problem I've had with my SVG's it somehow totally butchers the twinkle example. Since text isn't working anyway, I might try to backport the required changes to the older version of usvg and see how that turns out.

image

image

@StrikeForceZero
Copy link
Contributor Author

StrikeForceZero commented Jul 19, 2024

well i was able to backport the fixes to get the same results and in the process I realized why text isn't working.

So the only things left for this specific PR would be:

  • Fix this weird offset for some svgs for text (maybe fixed? see TODO)
  • Figure out why twinkle isn't rendering properly

Edit: I've figured out how to fix twinkle and subsequently strokes not being scaled properly in certain scenarios. The PathEvent needs to be transformed with a normalized transform without any scale and the scale applied in the vertex buffer (only for stroke), paths are just transformed PathEvents. However my math with the matrix might be wrong on normalizing the transform because without the rotation the strokes don't align properly. Alternatively, maybe I can find a way to transform just the vertex buffer like it originally was but working lol. I'll try again after a fresh brain. e1c4d09

@StrikeForceZero
Copy link
Contributor Author

StrikeForceZero commented Jul 20, 2024

Ok I think this is mostly at least feature parity or even improving since it's last release (besides the text handling regression from upgrading usbg on the twinkle example.) Fixed see edit

I'm going to do some more experimenting this weekend and see if I can find a way to properly reconstruct the twinkle SVG with the data that's being parsed before I take it out of draft, but anyone is welcome to review/test it with other svgs as is.


Edit:

Might just be an edge case svg as resaving it in inkscape makes it renderable in resvg

image


Edit 2:

Ah, its not up to spec

image

@StrikeForceZero StrikeForceZero marked this pull request as ready for review July 20, 2024 16:56
@StrikeForceZero StrikeForceZero changed the title Update to bevy 0.14 and usvg 0.42 Update to bevy 0.14, usvg 0.42, and several bug fixes Jul 20, 2024
@Weasy666
Copy link
Owner

Ok... wow. Thanks for the amazing work you are putting into this. 🙏
And sorry for my radio silence. I am a bit overwhelmed with work and was burned out a bit in regard to chasing Bevy releases and the constant changes to rendering.
I'll start to review this in the coming days.

@StrikeForceZero
Copy link
Contributor Author

Ok... wow. Thanks for the amazing work you are putting into this. 🙏 And sorry for my radio silence. I am a bit overwhelmed with work and was burned out a bit in regard to chasing Bevy releases and the constant changes to rendering. I'll start to review this in the coming days.

No worries, take your time. I'm just happy to have finally chased down most of the problems I've had trying to get non-rasterized SVG support working in Bevy :)

@Weasy666
Copy link
Owner

Looking good to me!
Thank you very much for the work you have put into this! I'll publish a new version after the merge. So, expect it on crates.io in about half an hour 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants