Skip to content

KRasterImporter

Alfish edited this page Sep 27, 2022 · 15 revisions

Source Image Import Settings

This window defines how to import source images from your project's Assets folder into the Unity Editor.
Select one or more image files in the Project window so that the import settings appear in the Inspector.
Enable the desired import method, then click Apply.

No import method is enabled by default. If you want, you can select one of the included KRasterImporter presets (or create your own preset) and use the button on the Inspector to set it as the default for the project.

You can hover the mouse on any field's label to show a tooltip explaining what it does.

Generate File

This is the recommended method, since that allows to use all features of Unity's built-in texture importer.
This will generate each image file on the specific path/name pattern you set.
You can then select these new texture asset files and import them as normal.

The default pattern generates the file on the same folder as the source image. This is usually appropriate for Image.
For Animation, you can use the pattern from the Generate Animation preset to put the files for each frame under the same <name>/ folder.

Variables (e.g. <name>) are used to specify the path pattern generically. This allows you to import many files at once.
Simply hover the mouse on Generate To for a tooltip explanation of each variable.

For example, if you want to change just the top folder under Assets to "Textures", you could use something like:

  • <root>/Textures/<subpath>/<name>.<ext>.<simple?png:exr>
  • <root>/Textures/_auto/<guid>.<simple?png:exr>

The Generate File importation method can use the External Program Mode when necessary - for example, when generating a file in any format other than PNG. Install Krita and enable the preference to use this mode. The <simple?png:exr> expression at the end will ensure that the PNG format is preferred when possible (since it's faster to generate), otherwise (when HDR or linear) EXR is used through the external converter program (Krita). If you have issues with the external converter, make sure that the called program has the correct export settings configured (e.g.: "flatten image" option).

You can also use a different format if desired. Formats natively supported by both Unity and Krita include:

  • PNG: recommended for simple sRGB images
  • EXR: recommended for HDR and for linear images
  • PSD: supports many features like multi-layer and HDR, but it's proprietary
  • TIFF: supports multi-layer and HDR, but can be heavier
  • TGA: can be heavier
  • BMP: inappropriate for alpha channel, can be heavier
  • JPEG: inappropriate for alpha channel, lossy
  • GIF: inappropriate for alpha channel, only 256 colors

Note that none of the settings below will be applied to the generated file's import settings. If you want to change the default texture import settings, you can create a custom TextureImporter preset pattern for a specific folder, according to your use case.

Import Image

You might prefer to import textures and sprites directly as sub-assets. Only single sprite mode is supported at the moment. This method has less options than the built-in importer, but, on the other hand, it may be more convenient to use.

This direct importation method uses the Internal PNG Mode, which reads the PNG data for the flattened layers (merged image) as it was rendered by the image editor. It doesn't require installing a separate program.

Most options here correspond to the same option in Unity's built-in Texture Importer or Sprite Editor, so only differences will be explained below.

Texture Name, Sprite Name

Name of the sub-asset. These fields allow the same variables as in the path patterns explained before. The default is <name>, which is the filename of the source image without the extension.

sRGB (Color Texture)

You probably want this enabled. If you're dealing with linear files, where you would need to disable this field, you have to be careful because the PNG data used in importation may still be in sRGB space even when the source file is linear. You'll see a warning if the plugin thinks this setting has the wrong value. When in doubt, it's simpler to use external mode to generate a separate EXR file for linear files and use the built-in importer instead of this.

Alpha Is Transparency

Leave it enabled unless you're using the alpha channel for something other than opacity. Note that no color dilation filter is applied; result can be slightly different from the built-in texture importer. If you choose an opaque format (no alpha channel), then this flag controls whether it should put the image on a black background or just discard the alpha channel.

Wrap Mode

Like in Unity's built-in TextureImporter, you can set it per-axis for the U and V coordinates individually.
To set both to the same value, you can use the convenient small dropdown at the right.

Texture Format

Similar to Unity's built-in TextureImporter, but only the options below are available.

  • DXT1 (Compressed RGB): Opaque colors, compressed. 64 bits per 4x4 block of pixels.
  • DXT5 (Compressed ARGB): Colors with alpha transparency, compressed. 128 bits per 4x4 block of pixels.
  • RGB8 (Uncompressed): Opaque colors, uncompressed. 8 bits per channel.
  • ARGB8 (Uncompressed): Colors with alpha transparency, uncompressed. 8 bits per channel.

DXT compression is lossy, but effect is minimized when higher resolutions are downscaled.
If you need a different format, quality/platform-specific overrides, or any other feature unavailable here (including HDR), use Unity's built-in importer instead of this direct importation method. To do so, you can use the external mode to generate a separate EXR file.

World Unit

What size in the sprite corresponds to 1 unit in the world. This is the sprite's Pixels Per Unit setting when the unit is set to px. Otherwise, this value will be set relatively to the image size or pixel density (ppi or px/cm) as set in the image editor.

  • % container: % of width or height, whichever is larger, per world unit.
    E.g., when it's 100% containing, then an unscaled image will fit inside a 1x1 world unit square without stretching.
  • % coverage: % of width or height, whichever is smaller, per world unit.
    E.g., when it's 100% covering, then: if an unscaled image has "portrait" aspect, its width will cover 1 world unit; if it has "landscape" aspect, height will cover 1 unit.
  • % width|height: Value is Pixels Per Unit relative to % of either width or height.
    E.g., 25% width means unscaled sprite width is 4 world units.
  • px: Value is the exact amount of Pixels Per Unit.
  • in|cm: Value is the amount of inches or centimeters per world unit, measured using the image's pixel density value. This allows you to design sprites using these physical units in the image editor.
    E.g., 100cm means 1 meter in the unscaled sprite is 1 world unit.

Pivot

Corresponds to the normalized Custom Pivot setting, where (0, 0) is bottom left and (1, 1) is top right.
Use the small dropdown to conveniently set the most common values.

Preview Area

The preview area shows info about the source image being inspected:

  • File extension (KRA, KRZ or ORA)
  • Image size in pixels (e.g.: 512×512)
  • If the file has animation frames:
    • Number of frames (e.g.: ×8)
    • Framerate (fps)
    • Duration (seconds)
  • Pixel density (ppi or px/cm)
  • Color format (e.g.: RGBA16f is HDR float 16-bit per channel)
  • Gamma (e.g.: sRGB, linear, γ=1.8)
  • Color profile name (in square brackets)
  • File length in bytes (e.g.: 1.2MiB)
  • When internal PNG info is shown:
    • PNG image size in pixels (when different)
    • PNG color format (e.g.: RGBA8)
    • PNG length in bytes (e.g.: 12.3KiB)

Clone this wiki locally