diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cbbacd..bb604d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [6.0.1] - 2021-09-21 +### Fixed +- Removed memory requirement check since we cannot properly determine if there will be enough memory to import the file (case 1357544) +- Fixed artifacts on images when flatten. +- Fixed exception "PsdInvalidException: Unrecognized layer section type" when importing certain files. + ## [6.0.0] - 2021-08-10 ### Fixed - Fixed performance regression in PSDImporter Editor (case 1349408) diff --git a/Editor/PSDPlugin/PhotoShopFileType/PsdLoad.cs b/Editor/PSDPlugin/PhotoShopFileType/PsdLoad.cs index 7efbef9..fa2fb4e 100644 --- a/Editor/PSDPlugin/PhotoShopFileType/PsdLoad.cs +++ b/Editor/PSDPlugin/PhotoShopFileType/PsdLoad.cs @@ -273,6 +273,10 @@ private static void SetPdnResolutionInfo(PsdFile psdFile, Document document) /// internal static void CheckSufficientMemory(PsdFile psdFile) { + /* + Remove memory check since we can't properly ensure there will + be enough memory to import + // Multichannel images have channels converted to layers var numLayers = (psdFile.ColorMode == PsdColorMode.Multichannel) ? psdFile.BaseLayer.Channels.Count @@ -296,6 +300,7 @@ internal static void CheckSufficientMemory(PsdFile psdFile) { throw new OutOfMemoryException(); } + */ } } } diff --git a/Editor/PSDPlugin/PsdFile/PsdFile.cs b/Editor/PSDPlugin/PsdFile/PsdFile.cs index 9e46e43..abb55a2 100644 --- a/Editor/PSDPlugin/PsdFile/PsdFile.cs +++ b/Editor/PSDPlugin/PsdFile/PsdFile.cs @@ -557,7 +557,10 @@ internal void VerifyLayerSections() if (depth < 0) throw new PsdInvalidException("Layer section ended without matching start marker."); break; - + + case LayerSectionType.Layer: // Nothing to do here yet. + break; + default: throw new PsdInvalidException("Unrecognized layer section type."); } diff --git a/Editor/Tasks/FlattenImageTask.cs b/Editor/Tasks/FlattenImageTask.cs index aa69bed..51c3b3e 100644 --- a/Editor/Tasks/FlattenImageTask.cs +++ b/Editor/Tasks/FlattenImageTask.cs @@ -111,11 +111,18 @@ public unsafe void Execute(int index) { int sourceIndex = sourceYIndex + j; int destIndex = destYIndex + j; - float alpha = buffer[sourceIndex].a / 255.0f; - premerge[destIndex].r = (byte)(alpha * (float)(buffer[sourceIndex].r) + (float)((1.0f - alpha) * (float)premerge[destIndex].r)); - premerge[destIndex].g = (byte)(alpha * (float)(buffer[sourceIndex].g) + (float)((1.0f - alpha) * (float)premerge[destIndex].g)); - premerge[destIndex].b = (byte)(alpha * (float)(buffer[sourceIndex].b) + (float)((1.0f - alpha) * (float)premerge[destIndex].b)); - premerge[destIndex].a = (byte)(alpha * (float)(buffer[sourceIndex].a) + (float)((1.0f - alpha) * (float)premerge[destIndex].a)); + Color sourceColor = buffer[sourceIndex]; + Color destColor = premerge[destIndex]; + Color finalColor = new Color(); + + var destAlpha = destColor.a * (1 - sourceColor.a); + finalColor.a = sourceColor.a + destColor.a * (1 - sourceColor.a); + var premultiplyAlpha = 1 / finalColor.a; + finalColor.r = (sourceColor.r * sourceColor.a + destColor.r * destAlpha) * premultiplyAlpha; + finalColor.g = (sourceColor.g * sourceColor.a + destColor.g * destAlpha) * premultiplyAlpha; + finalColor.b = (sourceColor.b * sourceColor.a + destColor.b * destAlpha) * premultiplyAlpha; + + premerge[destIndex] = finalColor; } } } diff --git a/package.json b/package.json index bee25fe..e07c86c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.unity.2d.psdimporter", - "version": "6.0.0", + "version": "6.0.1", "unity": "2021.2", "displayName": "2D PSD Importer", "description": "A ScriptedImporter for importing Adobe Photoshop PSB (Photoshop Big) file format. The ScriptedImporter is currently targeted for users who wants to create multi Sprite character animation using Unity 2D Animation Package.\n\nDocumentation for v5.0 is currently being updated.", @@ -11,19 +11,19 @@ ], "category": "2D", "dependencies": { - "com.unity.2d.animation": "7.0.0", + "com.unity.2d.animation": "7.0.1", "com.unity.2d.common": "6.0.0", "com.unity.2d.sprite": "1.0.0" }, "relatedPackages": { - "com.unity.2d.psdimporter.tests": "6.0.0" + "com.unity.2d.psdimporter.tests": "6.0.1" }, "upmCi": { - "footprint": "060330cf8095556874a02eb362ad40ff0df8455a" + "footprint": "a613628badeb5beba757c208c6433434512ee74d" }, "repository": { "url": "https://github.cds.internal.unity3d.com/unity/2d.git", "type": "git", - "revision": "bcbc5fb1cb18a1a4cf6e15325550ed4b8fbb21bc" + "revision": "b015022decd440f484d85cf6ee096c0ecaa60e30" } }