Skip to content

Commit 89be994

Browse files
committed
added normal map support
1 parent 518ba98 commit 89be994

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Alternatively, download or clone this repository and copy the contents of the
2222
* Import sprite sheets as AtlasTextures
2323
* Supports trimmed sprites (margin)
2424
* Supports MultiPack
25+
* Supports normal maps
2526

2627
## Usage (once the plugin is enabled)
2728

@@ -38,6 +39,10 @@ Alternatively, download or clone this repository and copy the contents of the
3839

3940
# Release notes
4041

42+
### 4.3.0 (2025-12-08)
43+
44+
* Support sprites with normal map (use CanvasTexture if normal map is present)
45+
4146
### 4.2.0 (2025-06-11)
4247

4348
* Remove sprites no longer present on a sheet

addons/codeandweb.texturepacker/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ config_version=3
33

44
name="TexturePacker Importer"
55
description="Importer for sprite sheets created using TexturePacker"
6-
version="4.2.0"
6+
version="4.3.0"
77
author="Andreas Loew / CodeAndWeb GmbH"
88
script="codeandweb.texturepacker_importer.gd"

addons/codeandweb.texturepacker/texturepacker_import_spritesheet.gd

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,17 @@ func _import(source_file, save_path, options, r_platform_variants, r_gen_files):
8787
printerr("Failed to load image file: " + sheetFile)
8888
return ERR_FILE_NOT_FOUND
8989

90-
create_atlas_textures(sheetFolder, sheet, image, r_gen_files)
90+
if sheet.has("normalMap"):
91+
var normalFile = source_file.get_base_dir()+"/"+sheet.normalMap
92+
var normalImage = ResourceLoader.load(normalFile, "ImageTexture")
93+
if not normalImage:
94+
printerr("Failed to load normal map file: " + normalFile)
95+
return ERR_FILE_NOT_FOUND
96+
97+
image = create_canvas_texture(sheetFolder, sheet, image, normalImage, r_gen_files)
9198

99+
create_atlas_textures(sheetFolder, sheet, image, r_gen_files)
100+
92101
delete_no_longer_existing_sprite_files(sheetFolder, r_gen_files)
93102

94103
# without this call Godot editor will not refresh its filesystem view
@@ -106,6 +115,18 @@ func create_folder(folder):
106115
printerr("Failed to create folder: " + folder)
107116

108117

118+
func create_canvas_texture(sheetFolder, sheet, diffuseTex, normalTex, r_gen_files):
119+
var canvasTex = CanvasTexture.new()
120+
canvasTex.diffuse_texture = diffuseTex
121+
canvasTex.normal_texture = normalTex
122+
var canvasTexFolder = sheetFolder+"/CanvasTexture"
123+
var canvasTexResource = canvasTexFolder+"/"+sheet.image.get_basename()+".tres"
124+
create_folder(canvasTexFolder)
125+
ResourceSaver.save(canvasTex, canvasTexResource)
126+
r_gen_files.push_back(canvasTexResource)
127+
return canvasTex
128+
129+
109130
func create_atlas_textures(sheetFolder, sheet, image, r_gen_files):
110131
for sprite in sheet.sprites:
111132
if !create_atlas_texture(sheetFolder, sprite, image, r_gen_files):

0 commit comments

Comments
 (0)