Builtin Library
- ..
- .metadata60 B
- README.md2.5 KB
- init.luau6.0 KB
- settings.luau476 B
README.md
SVG → Texture Importer
Bakes loose .svg writes into a first-class .texture asset.
What it does
When a .svg file is written loose into the VFS (not already inside a
typed-asset folder), this importer:
- Rasterizes the SVG via the engine's generic rasterizer
(
__svg.rasterize→ resvg/usvg/tiny-skia → straight-alpha RGBA → PNG), at the SVG's intrinsicviewBoxsize (clamped to 4096 px, aspect preserved). - Creates a
<name>.texture/asset throughasset.create, encoding the baked raster intodata.ztexand stamping the texture'ssettings.yaml. - Moves the original
<name>.svginside that.texture/folder so the vector source is never lost and stays linked to its baked raster.
logo.svg
↓ (write)
logo.texture/
data.ztex ← baked raster, encoded
settings.yaml ← the texture's settings
logo.svg ← original source, moved in
Settings
The importer's settings.luau declares textureSettings — the texture type's
settings, embedded — with a declared default of { filter = "nearest", textureType = "sprite" }, so a baked SVG is a crisp sprite (sRGB, with its
fully transparent texels filled with their neighbours' colour so filtering
never darkens its edges) unless the importer's settings say otherwise.
Whatever the group holds is the importer layer of the baked texture's
settings, and asset.settings(importerRef).textureSettings reports it.
The resulting .texture is usable anywhere a texture is accepted — bind it
to a material slot, hand it to the material toolbox
(material.fromTexture(logoTexture)), etc.
Claiming rules
- Claims any path ending in
.svgthat is not already inside a.texture/(so re-writes of the moved-in source don't re-bake). - Dispatch, origin-gating (only the originating client bakes in a
multiplayer session), content-gating (unchanged bytes are a no-op), and
re-entrancy all live in the importer type's
shared.module— this importer only implements the format-specificcanImport+importpair.
Re-baking
Like every importer, once the source is moved into its asset folder it is
quiescent. To re-bake after editing the vector, re-write a loose copy of the
.svg (or call the importer explicitly via its AssetRef:run(path)).
Related
texture.assetType— the.textureasset this produces.material.toolbox— turn the baked texture into a material in one call.__svg.rasterize— the underlying rasterization capability (Rust).