texturepacker-godot-plugin icon indicating copy to clipboard operation
texturepacker-godot-plugin copied to clipboard

[Feature-Request] Support for normal maps

Open NetroScript opened this issue 6 years ago • 2 comments

With TexturePacker you have the option to automatically create a normalmap file which has the same positions + regions for the supplied normalmaps as the texture file. But when using this plugin for godot the normal file which can be also generated is completely ignored.

A simple fix for a spritesheet (which I used in my project now) could be f.e. adding

		if sheet.has("normalMap"):
			var normalsheetFile = source_file.get_base_dir()+"/"+sheet.normalMap
			var normalimage = load_image(normalsheetFile, "ImageTexture", [])
			for sprite in sheet.sprites:
				sprite.filename += "_n"
			create_atlas_textures(sheetFolder, sheet, normalimage, r_gen_files)

after this (This code assumes that the file extensions are trimmed, otherwise you would have to change it slighty)

This also creates "empty" normalmaps (if the original spritesheet had no normalmap for a specific texture) instead of no normalmap at all- I don't know if this would be the intended functionality. Additionally it doesn't really leave room for customisation (if the user f.e. wanted a specific folder for all the normal maps).

But it would be nice if this or something similar was added to the import of spritesheets and tilesets

NetroScript avatar Nov 05 '18 17:11 NetroScript

Nice idea - but I need more time to investigate this.

CodeAndWeb avatar Jun 16 '20 07:06 CodeAndWeb

@NetroScript I had to modify the script above somewhat to get this working:

if sheet.has("normalMap"):
	var normalsheetFile = source_file.get_base_dir()+"/"+sheet.normalMap
	var normalimage = load_image(normalsheetFile, "ImageTexture", [])
	for sprite in sheet.sprites:
		var extension = sprite.filename.get_extension()
		var basename = sprite.filename.get_basename()
		sprite.filename="{0}_n.{1}".format([basename, extension])
	create_atlas_textures(sheetFolder, sheet, normalimage, r_gen_files)

2shady4u avatar Jan 15 '21 16:01 2shady4u