limage v0.2.2

WARNING: Requires Python to be installed

PSD (Photoshop, Krita, Gimp...) -> Godot.

Example files included. You can delete everything outside the "addons" folder.

Design in your prefered art tool. How you lay it out is how you get it out!
layers1 layers3
Draw origins + spawn points to make life easier.
points1 points2

Auto generate convenient code.

layers2

Tell Godot what kind of node you want the layer to be.
node1 node2

Auto polygon scene generator (WIP)

polygons

Features

  • Convert PSD to images + layer info.
  • Auto-generate scene where layer positions, visibility, and opacity are preserved in Godot.
  • Add origins to make rotations easier.
  • Many image formats, like WEBP.
  • Scale, quantize, and optimize images.
  • Images auto cropped to minimum size.
  • Optionally merge layers at build time, so they can stay seperate in your psd.
  • Only builds if there were changes.
  • Helper scripts:
    • Button: Pixel perfect sprite clicking, without a mask. (Sprite can scale + rotate!).
    • Customizer: Script generator for customizable content.
    • Cursorize: Call set_layer_as_cursor("layer_name") to set any layer as the cursor. (Will use origin to offset).
  • Polygon generator. (WIP! see Tags)

Getting Started

pip3 install psd-tools
  • Create a layered_images folder in Godot. res://layered_images.
  • Add .psd files. (Krita and Gimp can export .psd)
  • Activate the plugin. (Project > Project Settings > Plugins > Limage)
  • Click Limage at top of screen. (next to 2D, 3D, Script, Asset Lib)
  • Click generate.
  • The textures will be placed in a textures folder, and the data in a data folder.

Populating Scene

  • Create a scene in Godot.
  • Add LimageNode.gd script to it.
  • Drag data/name-of-your-psd .tres into the limage field.
  • Click the force_update toggle twice.

That should work. You could remove the LimageNode.gd if you like.

Every time you double click force_update it will update. Useful if you made changes. But it won't delete nodes. You can manually delete all the children to clear, and do a fresh generation.

Tags

Add tags in layer names, between []: layer_name [tag_1 tag2 tag-3]

Use () to set tags for all children. layer_group [tag1] (tag2 tag3)

Use (()) to set tags for all descendants. buttons ((button))

Tags can have values: background [parallax=10] which you can then get in Godot with limage.get_layer("background").tags.get("parallax").

  • x: Completely ignore layer. (Wont export image or layer info.)
  • visible: Will make layer visible, regardless of it's state in the psd.
  • !visible: ^
  • point: Won't generate an image, but will create an empty node in the scene. Useful for spawn points.
  • origin: Sets the origin of the parent group. If no parent, sets the global origin.
  • poly: (WIP!) Will generate a polygon scene. (Requires opencv-python and numpy)
  • button: Makes a clickable sprite button.
  • node: Tells Godot what node to use. my_light [node=Light2D]

These tags can be used on group layers.

  • origins: Children will be treated as points and used for layer origins, for easier rotations + scaling.
  • merge: "Flatten" children into one image.
  • options: Treat children as options for a sprite. (good for customizable objects.)
  • toggles: Treat children as optional child sprites that will be added/removed if enabled/disabled.

Settings

Export settings can be tweaked by including a json file next to the psd, with an identical name.

So next to layered_images/my_picture .psd include layered_images/my_picture .json with your settings.

# default settings
"path": "",						# location of psd if not in directory. (not implemented yet)
"seperator": "-",				# change to "/" and images will be stored in subfolders instead.

"texture_dir": None,			# if set, saves textures here
"data_dir": "data",				# if set, saves layer data here

# rescale textures
"scale": 1,

# in range of 0.0 - 1.0. makes rotation + flipping easier.
# creating a layer with an "origin" tag will replace this. 
"origin": [0, 0],

# you can choose any image format pillow + Godot support.
# but PNG, WEBP, and JPG are probably the most common.
# https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html
# https://docs.godotengine.org/en/stable/getting_started/workflow/assets/importing_images.html
"format": "WEBP", # WEBP can be A LOT smaller than png. and Godot supports it.

# can really decrease file size, but at cost of color range.
# https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.quantize
"quantize": False,

# default texture format settings
"PNG": {
	"optimize": True,
},

"WEBP": {
	"lossless": True,
	"method": 3,
	"quality": 80
},

"JPEG": {
	"optimize": True,
	"quality": 80
}

Todo

  • Better documentation.
  • Finalize polygon generator.
  • Normal map generation.
  • Blend mode shaders.
  • Optional padding for textures.
  • Text placement + preservation. (I only work with krita, which doesn't preserve text info when converting to psd.)

Customizer

If you include an options or toggles tag in any layer, a Godot script will be generated to make layer manipulation easier.

You can then replace LimageNode.gd with it.

You should override this rather than add code to it, as it will be replaced when regenerating.

GitHub

https://github.com/teebarjunk/godot-limage