Skip to content

2shady4u/godot-krita-importer

Repository files navigation

Godot Krita Importer banner

godot-krita-importer

Plugin for Godot Engine to automatically import Krita KRA & KRZ-files

Supported operating systems:

  • Mac OS X
  • Linux
  • Windows

Table Of Contents

Re-building Godot from scratch is NOT required, the proper way of installing this plugin is to either install it through the Asset Library or to just manually download the build files yourself.

Godot Asset Library

Godot Krita Importer is available through the official Godot Asset Library, and can be installed in the following way:

  • Click on the 'AssetLib' button at the top of the editor.
  • Search for 'Godot Krita Importer' and click on the resulting element.
  • In the dialog pop-up, click 'Download'.
  • Once the download is complete, click on the install button...
  • Once more, click on the 'Install' button.
  • Activate the plugin in the 'Project Settings/Plugins'-menu.
  • All done!

Manually

It's also possible to manually download the build files found in the releases tab, extract them on your system and run the supplied demo-project. Make sure that Godot is correctly loading the libkra_importer.gdextension-resource and that it is available in the res://-environment.

An example project, named "demo", can also be downloaded from the releases tab.

Godot Krita Importer automatically imports any and all files with the KRA and KRZ-extensions and this should be sufficient for most purposes.

Krita Godot
Krita source file Imported result in Godot

Following import options are available from the import tab:

name default description
ignore_invisible_layers false Do not import layers that are set to invisible in Krita.
texture_filter CanvasItem.TEXTURE_FILTER_PARENT_NODE Texture filter that is used for all created Sprite2D nodes.
crop_to_visible true Crop all textures to the visible portion of their respective image.
center_sprites true Set all textures to centered by setting the centered property in the created Sprite2D nodes.
import_as_files false (false) Include the raw layer data directly into the created Sprite2D nodes.
(true) Save all textures to PNG files and reference those files in the created Sprite2D nodes.

In cases where more advanced importing functionality is wanted or required, the plugin exposes several variables and methods that hopefully allow enough freedom to easily extend the importer.

  • layer_count (Integer, default=0)

    Number of loaded layers at the top level of the document's layer structure.

  • verbosity_level (Integer, default=1)

    Verbosity level of the importer library, following levels are available:

    Level Description
    QUIET (0) Don't print anything to the console
    NORMAL (1) Print essential information to the console
    VERBOSE (2) Print additional information to the console
    VERY_VERBOSE (3) Same as VERBOSE

    NOTE: VERBOSE and higher levels might considerably slow down the importing process due to excessive logging.

  • void load( String path )

    Load a KRA or KRZ-archive file and populate the internal layer structure.

  • Dictionary layer_data = get_layer_data_at( Integer layer_index )

    Return the layer_data of the layer at the given top-level index.

  • Dictionary layer_data = get_layer_data_with_uuid( String UUID )

    Return the layer_data of the layer with the given UUID.

1. Why are the colors of my imported .kr(a/z)-file different in Godot?

The C++ library libkra, used for importing Krita documents into Godot, does not support nor implement any conversion between color profiles. As a result, the color profile used for your Krita document should be the exact same as the one implemented in Godot otherwise the color of your pixels will different across applications.

In the case of Godot, this means that you'll have to choose the sRGB IEC61966-2.1 color profile for all your Krita documents (Image -> Properties).

Future improvements in the libkra-library might see the implementation of color profile awareness and conversion, most likely by using the Little CMS library as an additional external dependency in the project.

2. Why is my favorite color space XYZ not supported by this plugin?

Only a small selection of color space formats are currently supported by this plugin. This might be because one of two possible reasons:

  1. The C++ libkra-library does not implement this format
  2. Godot does not natively support the format

Supported formats can be listed as follows:

Supported by libkra? Supported by Godot? (Image::Format)
RGBA ✔️ Image::FORMAT_RGBA
RGBA16 ✔️ ❌*
RGBAF16 ✔️ ❌*
RGBAF32 ✔️ Image::FORMAT_RGBAF
CMYK ✔️ ❌*

* Godot does not natively support this color space format

In cases where your favorite color format XYZ is natively supported by Godot, but is unfortunately blatently absent from the above color space support matrix, please feel free to open an issue in this repository.

3. Is support for *.xcf, *.ora, *.psd, etc... in the list of planned features?

No other file formats will ever be supported.

Build instructions for all supported platforms can be found here.

Please feel free to open pull requests as to merge any contributions into this repository.