CodeAndWeb/texturepacker-godot-plugin

[Feature-Request] Support for normal maps

NetroScript opened this issue · 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

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

@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)