SVG Asset Support

Aperta
#26,585 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust

Direzione di ricerca

The issue outlines four stages: start with exr_texture_loader.rs in bevy_image and the ktx2_buffer_to_image implementation in ktx2.rs. First identify the existing asset loader and image mipmap patterns, then choose one stage and check its scope with the maintainers. Done means completing a stage's stated behavior and its relevant checks; the full issue also includes vector assets, UI raster caching, and Feathers integration.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

C-Feature S-Needs-Triage

What problem does this solve or what need does it fill?

SVGs are a highly requested format for UI and 2D graphics. We should support them first-party with a particular emphasis on supporting pixel perfect rendering in UI.

We're going to use resvg as a cpu backend and implement two asset types; svg files loaded as Image Assets that can be used anywhere, and svg files loaded as Svg assets that can be used in UI.

Progressive implementation

Adding svg to support to bevy in four stages:

1. Minimal .svg -> Image at fixed size

Users can load svgs as images, but they rasterize at a single fixed size.

  • Add an svg feature, like png. Currently ony enabled in feathers
  • Add SvgLoader (type Asset = Image) in bevy_image (see exr_texture_loader.rs for an example)
  • Use resvg with default-features = false (no text, no system fonts, no raster images, no svgz)
  • asset_server.load("icon.svg") should work in ImageNode, Sprite, anywhere an Image works.
2. Mip chain rasterizing

Svg image assets get mipmapping with reasonable defaults.

  • Render the svgs at some fixed sizes and mipmap them
    (Reference ktx2_buffer_to_image implementation in ktx2.rs)
  • OK looking svgs at multiple sizes.
3. Vector assets + Raster cache

Users can load svgs as svg assets, which can be rasterized to exact sizes.

  • Add an Svg asset type and SvgAssetLoader

    • This holds the parsed tree in memory and allows consumers to request rasterizations
    • Grabbing sections of the svg should be available too--ex using node_by_id to raster a specific node
  • Add a SvgRasterCache resource to hold a map from raster settings, assetid, and size to raster results.

  • UI component that holds an svg handle and, after determining size, requests new rasters.

  • Use screen dpi

  • Pixel perfect svgs in UI!!

Edge cases Re-rasterizing on frequent size changes could be CPU intensive. This probably isn't an issue for our feathers use case.

4. Use SVGs in Feathers

Open svg workflow up to designers.

  • Replace existing .pngs with svg sources
  • Update ThemedIcon behavior
  • svgs are in feathers!
Currently Out of Scope
  • Swappable backends, GPU backend
  • Build time baking with LoadTransformAndSave so games using svg image assets can ship without resvg
  • DynamicTextureAtlasBuilder support
  • Svg <text> with bevy_text fonts
  • Svg window icons https://github.com/bevyengine/bevy/pull/21259
  • Svg custom cursors
  • SDF / MSDF
  • Embedded images and hrefs, .svgz
Lingua principale
Rust
Stelle
50k
Fork
5.1k
Merge medio
2g 20h
PR unite (30g)
129

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bevyengine/bevy

Tutte le issue di bevyengine/bevy

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.