Need help with SpriteDicing?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

Elringus
765 Stars 94 Forks MIT License 145 Commits 1 Opened issues

Description

Unity extension for lossless sprite texture compression

Services available

!
?

Need anything else?

Contributors list

# 30,333
C#
Unity
unity3d
google-...
150 commits

CodeFactor codecov

This plugin is used in Naninovel — visual novel engine extension for Unity. Check it out on the Asset Store!

Installation

Use UPM to install the package via the following git URL:

https://github.com/Elringus/SpriteDicing.git#package
or download and import SpriteDicing.unitypackage manually.

Minimum supported Unity version: 2019.3

Description

Sprite Dicing is an extension for Unity game engine allowing to split a set of sprite textures into dices, discard identical ones, bake unique dices into atlas textures and then seamlessly reconstruct the original sprites at runtime.

The technique allows significantly reducing build size when multiple textures with identical areas are used. Consider a visual novel type of game, where multiple textures per character are used, each portraying a different emotion; most of the texture space is occupied with identical data, while only a small area varies:

These original five textures have total size of 17.5MB. After dicing, the resulting atlas texture will contain only the unique areas of the original textures and consume just 2.4MB, effectively compressing the textures by 86.3%.

How to use

  1. Create a
    DicedSpriteAtlas
    asset using
    Assets -> Create -> Diced Sprite Atlas
    menu command, select it;
  2. Specify
    Input Folder
    — project directory, containing the source textures to process. You can drag-drop a folder from the project hierarchy window or select one with object picker;
  3. Press
    Build Atlas
    button and wait for the procedure to finish;
  4. Generated sprites will appear inside the atlas asset; select any of them and drop to the scene.

Atlas Generation Options

You can optionally configure atlas generation settings via the editor inspector window.

| Option | Description | --- | --- | | Decouple Sprite Data | Whether to save sprite assets in a separate folder instead of adding them as childs of the atlas asset. | | Default Pivot | Relative pivot point position in 0 to 1 range, counting from the bottom-left corner. Can be changed after build for each sprite individually. | | Keep Original | Whether to preserve original sprites pivot (usable for animations). | | Atlas Size Limit | Maximum size of a single generated atlas texture; will generate multiple textures when the limit is reached. | | Force Square | The generated atlas textures will always be square. Less efficient, but required for PVRTC compression. | | Pixels Per Unit | How many pixels in the sprite correspond to the unit in the world. | | Dice Unit Size | The size of a single diced unit. | | Padding | The size of a pixel border to add between adjacent diced units inside atlas. Increase to prevent texture bleeding artifacts (usually appear as thin gaps between diced units). Larger values will consume more texture space, but yield better anti-bleeding results. Minimum value of 2 is recommended in most cases. When 2 is not enough to prevent bleeding, consider adding a bit of

UV Inset
before increasing the padding. | | UV Inset | Relative inset of the diced units UV coordinates. Can be used in addition to (or instead of)
Padding
to prevent texture bleeding artifacts. Won't consume any texture space, but higher values could visually distort the final result. | | Input Folder | Asset folder with source sprite textures. | | Include Subfolders | Whether to recursively search for textures inside the input folder. | | Prepend Names | Whether to prepend sprite names with the subfolder name; eg:
SubfolderName.SpriteName
. |

All the above descriptions are available as tooltips when hovering corresponding configuration options in the editor.

UI

To use the diced sprites in UI (eg,

Image
component), enable
Use Sprite Mesh
. In case the option is not available, make sure to assign a source image.

Animation

It's possible to use diced sprites for animation. Make sure to enable

Keep Original Pivot
when generating the atlas to preserve relative positions of the generated sprites. An example on animating diced sprites is available in "Animation" scene.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.