• 中文
  • png压缩到unity会产生黑边

  • Modificato
Related Discussions
...

使用spine导出后的文件正常导入unity是没有任何问题的,但是因为导出的png图片体积较大,我会在https://imagecompressor.com/等压缩网站(尝试过许多其他网站也会有同样的问题)上压缩一遍png图片,但是再导入unity之后会产生一些问题。下面图片分别是我
勾选premulti alpha(预乘alpha)设置选项(1)、导入到unity的表现(2)以及使用 bleed(溢出)设置选项(3)、导入到Unity(连接处会产生黑边)的表现(4),图片都经过了压缩才会产生这些问题。有什么办法可以压缩图片体积的同时不会产生这些问题?期待您的回复,谢谢!

您好。在检查设置是否正确时,请不仅检查材质的设置,也要检查导入的纹理设置。例如,如果您导入的是启用了 Premultiplied Alpha(预乘alpha)的导出纹理,您需要确保在纹理设置中启用 sRGB(Color Texture),并禁用 Alpha Is Transparency。关于正确的设置组合,请参见本节文档。
[url=http://zh.esotericsoftware.com/spine-unity#%E9%AB%98%E7%BA%A7


Premultiplied-%E5%92%8C-Straight-Alpha-%E5%AF%BC%E5%85%A5]spine-unity 运行时文档: 高级 Premultiplied 和 Straight Alpha 导入[/url]

如果纹理设置也是正确的,而你的骨架仍然得到一个奇怪的外观,请让我们知道。


Hi,

When checking that the settings are correct, please check not only the material settings, but also the imported texture settings. For example, if you import textures exported with Premultiplied Alpha enabled, you need to make sure that sRGB (Color Texture) is enabled and Alpha Is Transparency is disabled in the texture settings. See this section of the documentation for the correct combination of settings:
[url=http://zh.esotericsoftware.com/spine-unity#%E9%AB%98%E7%BA%A7


Premultiplied-%E5%92%8C-Straight-Alpha-%E5%AF%BC%E5%85%A5]spine-unity 运行时文档: 高级 Premultiplied 和 Straight Alpha 导入[/url]

If the texture settings are also correct and your skeleton still get a strange appearance, please let us know.

我检查了我的设置,确保设置应该没有问题,在png图片没有压缩之前看起来非常完美,但是png体积过大,压缩之后就不正常了,所有的设置都是一样的,如图所示是我导出是启用了premulti alpha并导入Unity的表现。我再想是不是问题出在了压缩上,我是用的是这个网站进行的png压缩。https://imagecompressor.com/
或者你们有什么好的办法能够减小png体积?




啊,我现在明白了。谢谢你添加的信息。也许是那个网站的压缩将图像转换成了Straight Alpha。我想,使用直线阿尔法设置应该可以。至于你所附的(4)图中看到的轮廓问题,我怀疑这是压缩的一个伪影,增加纹理打包器设置中的填充 X/Y量可能会解决这个问题。


Ah, I see now. Thank you for adding the information. Perhaps the compression on that web site has converted the image to Straight Alpha. I think using straight alpha settings should work. As for the problem with the outlines seen in the (4) image you attached, I suspect that it is an artifact of compression, increasing the amount of Padding X/Y in the texture packer settings might solve it.

感谢您的回复,现在看来问题应该是出在了压缩上面,我使用straight alpha 并增加了导出时padding的值,好像没有明显的变化,这是对比以及使用straight alpha的图片的设置。这可能是一个难以解决的问题,或者有没有可能有其他压缩图片体积但不影响表现的方法?


I am sorry to hear that it was not resolved. I tried the Online Image Compressor you shared using the Spineboy's texture, and I could see the same artifacts in the outlines of some images. The compressor does not seem to have very fine quality settings, so it may be difficult to adjust it so that such artifacts do not occur with that. Here is the result when tested with Spineboy (Click to enlarge and you can easily see the difference) :

An alternative might be to use Spine 4.1 to compress the texture. The latest 4.1-beta has greatly enhanced the PNG export settings, allowing for size reduction while maintaining clean image quality. As a test, I created a Spine project with only the texture placed and compressed it as follows:


The result is here:

Texture size with no compression: 3.3MB
Texture size compressed using Spine 4.1.26-beta: 533KB

However, it will be tedious to do the export manually, so it is better to write a script and run it with CLI; if you run Spine via CLI, you can temporarily launch 4.1-beta and do the export without changing the editor version which you are using. This should be more efficient.

I just wanted to show one of the possibilities that might allow you to complete the whole process using only Spine, and I hope you understand in advance that it may not be a perfect method.

If there is anything that is unclear or you would like to ask additionally, please do not hesitate to let us know.

非常感谢您的回复,虽然比较繁琐,但是可以解决当下的问题!
希望后续版本可以在打包纹理的时候附带一个图片压缩的选项,这会方便很多,再次感谢你的回复!

希望后续版本可以在打包纹理的时候附带一个图片压缩的选项,这会方便很多,再次感谢你的回复!

你是对的。路线图上还没有这个问题,所以我们在这里创建了这个问题。
You are right. There was no issue on the roadmap yet, so we created the issue here:
https://github.com/EsotericSoftware/spine-editor/issues/656

在我之前给你的回复中,我向你展示了如何使用Spine优化你的地图集页面,但现在使用oxipng会更方便。Oxipng是一个命令行工具,它可以在保持漂亮的图像质量的同时进行优化,而且速度非常快。例如,可以使用以下命令进行优化。:
In my previous reply to you I showed you how to optimize your atlas page using Spine, but using oxipng would be easier for now. Oxipng is a command-line utility, which can be optimized while maintaining beautiful image quality and is very fast. For example, the following commands can be used for optimization:

oxipng 

---

nx -i 0 -o 4 

---

strip all your-image.png

你可以在这里安装它(这不是我们的产品)。:
You can install it here (This is not our product):
https://github.com/shssoichiro/oxipng