• Unity
  • Black Artifacts Outline Texture Images

Hello All,

The .PNG file that I have received from my animator is full of weird black pixels that surround all of the body parts.
Example:
https://i.ibb.co/QCkH0Mr/image.png

These do not exist at all on the original artwork that I provided. It's making the outlines of the animation look very grainy and staticky. :tear:

Is there a way to fix this issue? :think:

Related Discussions
...

The texture seems to be exported as Premultiply alpha. This means pixel RGB values were multiplied by the alpha value. Using Premultiply alpha is the default setting and recommended in general. Please see the FAQ for more information:
spine-unity Runtime Documentation: Visual

Misaki escribió

The texture seems to be exported as Premultiply alpha. This means pixel RGB values were multiplied by the alpha value. Using Premultiply alpha is the default setting and recommended in general. Please see the FAQ for more information:
spine-unity Runtime Documentation: Visual

Hi Misaki! Thank you for the reply! 🙂

I reviewed the page that you linked but I am still a bit confused. :think:
Yes, it was exported using Premultiply alpha. The documentation says that the settings in Unity don't match. But the black artifacts are there before I even import it to unity.

Does that mean that I need to edit the original source art?
If so, is there something specific I can do? Thank you!

Does that mean that I need to edit the original source art?

No, you don't need to edit the texture if you use the Premultiply alpha workflow. In the Premultiply alpha workflow, the black border will not show at runtime. It may seem complicated, but it is advantageous for graphics processing math if the pixel RGB values are multiplied by the alpha value preliminarily. If you are interested in the details you can see it here:
Premultiplied Alpha Guide

Thank you for the assistance, Misaki.

My animator has confirmed that they are exporting as PMA.

Though, it appears I am still seeing what I think is a transparency issue.
I am seeing either a dark or white outline for transparency depending on the camera position:


I have all of my settings in Unity set for Premultiply Alpha:

How can I resolve this? :think:

My animator has confirmed that they are exporting as PMA.

Did you perhaps modify the exported png textures? An image editor such as Photoshop might mess with RGB values of pixels where alpha=0. When mipmaps are enabled, this leads to additional problems.

Harald escribió

My animator has confirmed that they are exporting as PMA.

Did you perhaps modify the exported png textures? An image editor such as Photoshop might mess with RGB values of pixels where alpha=0. When mipmaps are enabled, this leads to additional problems.

Thanks for the reply, Harald. 8)

No, I didn't do any kind of editing to the exported .PNG file.

I still have the original .PSD file that I provided my animator to work with.
Is there anything I can check to verify nothing is messing with the RGB values of the pixels where alpha=0?

Additionally, here are the export settings that my animator is using:

In the Texture Packer Settings, what 'Filter Settings' and 'Format' should be used for Premultiplied Alpha and the best color quality?


Following up on this, when I uncheck "Generate Mipmaps" for the texture, the issue goes away.
However, Mipmaps are 100% necessary... is there a fix for this?

Edit: I also found this:

It looks like there is a bug with using sRGB + Mipmaps + Premultiplied Alpha, is that correct?
If so, is there a timeline when this is going to be fixed? :think:

PayasoPrince escribió

It looks like there is a bug with using sRGB + Mipmaps + Premultiplied Alpha, is that correct?

If you have enabled sRGB and Mipmaps on PMA textures at the same time, then your settings are incorrect. You should see a warning message in the console window that tells you exactly that. You should see this message every time you modify the texture settings and apply them, and once every time you start up Unity. Do you not receive this warning in your project, or did you just overlook it?

PayasoPrince escribió

If so, is there a timeline when this is going to be fixed? :think:

We don't want to put pressure on you to fix your texture settings, we leave the timepoint to you 😉 😃.
Joking aside: unfortunately there is nothing that can be done about it on our end, it's how Unity generates mipmaps with these settings enabled, unfortunately we have no way to tell it "it's a PMA texture" other than disabling sRGB (color texture).

Misaki's original posting that you posted a screenshot of was unfortunately a bit incorrect, it should say: "we have added a warning message whenever you enable mipmaps with sRGB on PMA textures". There shall be no "automatic optimization" of texture settings, since there might always be reasons for having textures setup like that.

We will add a special documentation section about mipmaps and this special case on the spine-unity documentation page. Sorry for the troubles it caused!

Ah, gotcha. Thank you for clarifying that for me, Harald!

I guess my last question would be, turning off sRGB will result in a loss of color range, correct?
I'm a complete novice with this topic, but from what I'm reviewing it seems like sRGB is for a wider range of colors that HDR monitors can take advantage of. Can turning this off result to banding if your texture has a wide range of colors? Am I in the right ballpark with this?

PayasoPrince escribió

I guess my last question would be, turning off sRGB will result in a loss of color range, correct? I'm a complete novice with this topic, but from what I'm reviewing it seems like sRGB is for a wider range of colors that HDR monitors can take advantage of.

No, this has nothing to do with precision or color range, no need to worry. sRGB just declares that the color information contained in a texture is in sRGB space and needs conversion to linear space (basically making all values lower by approximately pow(srgbColor, 2.2)) when rendering in linear space.

However, since PMA textures shall anyway only be used in Gamma color space, and I have found confirmation here that this setting only matters when using Linear color space, having sRGB (Color Texture) disabled should be safe to be declared as the new default setting for PMA textures. I will perform some more investigations and update the documentation accordingly.

Harald escribió
PayasoPrince escribió

I guess my last question would be, turning off sRGB will result in a loss of color range, correct? I'm a complete novice with this topic, but from what I'm reviewing it seems like sRGB is for a wider range of colors that HDR monitors can take advantage of.

No, this has nothing to do with precision or color range, no need to worry. sRGB just declares that the color information contained in a texture is in sRGB space and needs conversion to linear space (basically making all values lower by approximately pow(srgbColor, 2.2)) when rendering in linear space.

However, since PMA textures shall anyway only be used in Gamma color space, and I have found confirmation here that this setting only matters when using Linear color space, having sRGB (Color Texture) disabled should be safe to be declared as the new default setting for PMA textures. I will perform some more investigations and update the documentation accordingly.

You're the best!

14 días más tarde

Sorry for the long delay! We have just adjusted the new default PMA settings in the spine-unity runtime to have sRGB (Color Texture) disabled, which is now reflected on the spine-unity documentation page and in the FAQ section.

Changelog.txt escribió
  • PMA textures now have sRGB (Color Texture) disabled by default, the preset template PMATexturePreset.preset has been adjusted accordingly. As PMA textures are only allowed with Gamma color space, sRGB (Color Texture) shall be disabled to prevent border artifacts when mipmaps are enabled. In Gamma color space having this setting disabled has no drawbacks, only benefits.

New 4.1 and 4.2-beta spine-unity unitypackages have been released, they are available for download here as usual:
spine-unity Download
Please note that we didn't update the existing Spine Examples sample skeleton atlas texture settings on the 4.1 branch to not break any existing projects. The PMATexturePreset.preset file is updated on 4.1 however, which will automatically import newly added textures with the proper settings.

For later reference: This issue has been tracked under this issue ticket:
https://github.com/EsotericSoftware/spine-runtimes/issues/2187