Wiki

Clone wiki

KRaster Importer for Unity / KRasterImporter

Source Image Import Settings

This 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.

Source Image Import Settings in Unity Inspector: Generate File

The default pattern generates the file on the same folder as the source image. If Generate File is set to Animation, it will automatically group the files for each frame under the same <name>/ folder.

Parameters (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 parameter.

For example, if you want to change just the top folder under Assets to "Textures", you could use one of these:

  • <root>/Textures/<subpath>/<name>.<ext>.<format>
  • <root>/Textures/_auto/<guid>.<format>

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 <format> parameter at the end will ensure that exr is used only when appropriate (since it requires the external converter program), otherwise png is preferred. If you have issues with the external converter, make sure the last used export settings for that format in Krita are right (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 all simple images
  • EXR: recommended for linear HDR color images
  • TIFF: used more in printers and scanners
  • PSD: supports many advanced features, but it's proprietary
  • TGA: simple format, but it's technically proprietary
  • BMP: inappropriate for alpha channel or for compression
  • JPEG: inappropriate for alpha channel and uses lossy compression
  • GIF: inappropriate for alpha channel and uses only 256 colors

You should generally leave Generation Mode in Automatic, so the plugin automatically detects whether it should use Internal PNG Mode or External Program Mode. However, if you believe a specific file should be using a different mode, you can force it on just that file.

If you want to change the default texture import settings for the generated files, you can create custom TextureImporter preset patterns for their specific folders, according to your use case.

Import Image

You might prefer to import textures and sprites directly as sub-assets. To do so, set the Import Image field. When it's set to Texture 2D, you can also import sprites by setting Sprite Mode.

Only single sprite mode is supported at the moment. The sub-assets will have the same name as the source image file.

This direct importation method has less options than the built-in importer, but, on the other hand, you may prefer its convenience of grouping assets together. It uses the Internal PNG Mode, which reads the flattened PNG data (merged image) as it was rendered by the image editor. It's fast and doesn't require installing any 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.

Source Image Import Settings in Unity Inspector: Import Image - Sprite

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 instead use external mode to generate a separate EXR file for linear files and use the built-in importer on that file.

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 to import as an opaque format (no alpha channel), then this flag controls whether it should put the image over a black background or just discard the alpha channel.

Wrap Mode

You can set a single value or set it per-axis individually. To show the field for each axis, change the value in the little dropdown at the right. Change the axes to the same value to unify the fields again.

Format

Base format for the texture. The actual format will depend on the platform target, subtarget and the compression option.

  • Automatic: Automatically selects an appropriate format. No alpha channel when all pixels are opaque.
  • RGBA8: Truecolor + alpha channel. 32bpp.
  • RGB8: Opaque truecolor. 24bpp.
  • RG8: Red and green channels. 16bpp.
  • R8: Red channel. 8bpp.
  • RGBA4: 4096 colors + alpha channel. 16bpp.
  • R5G6B5: 65536 opaque colors. 16bpp.

If you need a different format, platform-specific overrides, or any other feature unavailable here (including HDR), generate a separate file and use Unity's built-in importer instead of this direct importation method. Only in external mode you can create EXR files.

Compression

This setting controls both the format used for compression and compression quality. Selecting None or Low Quality makes assets be imported faster. High Quality is slower to compress.

You can also use the Texture Compression field in Asset Import Overrides, in Build Settings to force fast or no compression during development. However, note that changes may only affect future importations, i.e. the Apply Overrides button may only cause the built-in texture importer to re-run. After applying the change, if you want to also update all textures from this importer right away, search for t:SourceImage in Project, select all results and click Assets menu > Reimport.

Margin

Amount of space around the whole image to ignore when creating sprites. This works like a cropping operation.

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 full image size (regardless of margin) or to pixel density (ppi or px/cm) as set in the image editor.

  • px: Value is the exact amount of Pixels Per Unit.
    E.g., 100px means 100px in the unscaled sprite is 1 world 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.
  • % width, % height: Value is Pixels Per Unit relative to % of either width or height of full image.
    E.g., 25% width means unscaled sprite width is 4 world units (if sprite is full image without margin).
  • % container: % of width or height of full image, whichever is larger, per world unit.
    E.g., when it's 100% containing, then an unscaled full image will fit inside a 1x1 world unit square without stretching.
  • % coverage: % of width or height of full image, whichever is smaller, per world unit.
    E.g., when it's 100% covering, then: if an unscaled image has "portrait" aspect, its full width will cover 1 world unit; if it has "landscape" aspect, full height will cover 1 unit.

Pivot

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

Preview Area

Source Image in Unity Inspector: 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 (e.g.: @8fps)
    • Duration (in seconds, e.g: 0.25s)
  • Pixel density (ppi or px/cm)
  • If the color space is recognized:
    • Color format (e.g.: RGBA16f) composed of:
      • Color model (e.g.: RGBA, GrayA, CMYKA, YCbCrA)
      • Bit depth per channel (8-bit, 16-bit, 32-bit)
      • Range (if it ends with f, channels are float, which allows HDR; otherwise it's integer)
    • Tone response curve (TRC):
      • linear (gamma=1) or decoding gamma value (e.g.: gamma[2.2])
      • sRGB or another trc[...] (e.g.: BT.709, PQ, L*)
    • Color gamut:
      • sRGB or another gamut[...] (e.g.: Rec2020, DisplayP3, AP1)
  • If color space couldn't be inferred:
    • Color profile name (icc[...])
  • 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)

Home

Updated