Table of Contents

Importing Assets

This package comes prepared to import shapes from SVG files.

  • Closed shapes (closed paths, and all other shape primitives) are imported as signed distances;
  • Open shapes (paths that do not have a fill) are imported as unsigned distances from their lines;
  • Other information such as fills, strokes, filters, and gradients, is ignored.

I intend to write a more complete generator eventually, but this should allow for a good range of use-cases already.

Importer Settings

Screenshot of the inspector for an SVG file

Field Description
Distance Field
Format The desired format for the resulting distance field. Different formats support different features, see DistanceFieldFormat for more information.
PixelRange How many pixels wide in the distance field texture should the transition from "completely inside the shape" to "completely outside the shape" be.
MaximumStraightAngle Inner angles greater than this value will be considered not a corner, and be exempt from the corner-preserving technique.
Sprite
PixelsPerUnit The pixel-per-unit of the generated sprite, see the Unity documentation for more details.
Extrude Amount of pixels of extra padding to include in the sprite's mesh. Useful when using Sprite shadows, as they are only rendered within a sprite's mesh.

Settings such as the Sprite's pivot and borders can be set using Unity's Sprite Editor, if it is installed.

Multiple sprites

Sometimes it is useful to have a single "spritesheet" file. This is supported, by marking each individual "sprite" you want to export with the x-kroltan-subfigure="SomeUniqueName" attribute.

This will import the entire document as a single distance field texture, with one Sprite sub-asset corresponding to each subfigure, named after the attribute.

If no such attributes are present, then the entire document's viewport will be imported as a single sprite.

Choosing a Format

The provided shaders expect a multi-channel format to work at all. However, some effects also require a true distance field.

Generally there is little reason to not import your shapes with both multi-channel and true formats enabled. But if you are optimizing build size, then you should understand what format is appropriate for your application.

Below you can find the required formats for every feature of the included shaders:

Shader Feature Requires True Distance
MSDF Sprite No
Outline Mode = Off No
Outline Mode = Sharp No, but it helps reduce artifacts
Outline Mode = True Yes
Shadow Yes
MSDF Decal No
Normals from Contour No

For custom shaders, please see the Guide: Custom Shaders guide, which explains how to implement and use them.