- Editado
Strange artifacts when use ATF texture and Additive blending
As the screenshot below shows, when I pack the sprite's texture as ATF format, at the same time check 'additive' blending option at the slot, then the additive object just doesn't show up and only darken artifact shows behind the character...
I'm using the runtime of starling version.
please help me with this problem.....
Normal PNG texture Image removed due to the lack of support for HTTPS. | Show Anyway
Using ATF (both character and background object) Image removed due to the lack of support for HTTPS. | Show Anyway
(<
Just a curious bystander)
What's ATF? And it looks like it's writing to a depth buffer or something. It's definitely masking something.
Also, even on the PNG situation, it looks like some misinterpretation going on. The shine has a weird black border.
Alcohol, Tobacco & Firearms?
Additive uses BlendMode.ADD instead of BlendMode.NORMAL for drawing the slot attachment, the rest is up to Starling.
Detailed explanation about ATF :
http://www.adobe.com/devnet/flashruntimes/articles/introducing-compressed-textures.html
http://www.adobe.com/devnet/flashruntimes/articles/atf-users-guide.html
http://jacksondunstan.com/articles/2040
ATF texture can save a lot of GPU memory and loading time, very helpful.
I found that those darken artifacts appear when:
- All textures used nearby are ATF texture (including none-spine object)
- some part of spine object uses 'Additive' blending
- that additive blending object also has 'color' animation (mainly fade-out effect using alpha)
I also found that using 'SCREEN' blending instead of 'ADD' can prevent darken artifact.
I edited code here :
https://github.com/EsotericSoftware/spine-runtimes/blob/master/spine-starling/spine-starling/src/spine/starling/SkeletonSprite.as#L110
I'm not sure if this is related with ATF texture's none premultiplied alpha feature.
The code below is from starling.display.BlendModes.as, which was some fix for similar ATF artifact bug (from starling version 1.3)
private static var sBlendFactors:Array = [
// no premultiplied alpha
{
"none" : [ Context3DBlendFactor.ONE, Context3DBlendFactor.ZERO ],
"normal" : [ Context3DBlendFactor.SOURCE_ALPHA, Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA ],
"add" : [ Context3DBlendFactor.SOURCE_ALPHA, Context3DBlendFactor.DESTINATION_ALPHA ],
"multiply" : [ Context3DBlendFactor.DESTINATION_COLOR, Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA ],
"screen" : [ Context3DBlendFactor.SOURCE_ALPHA, Context3DBlendFactor.ONE ],
"erase" : [ Context3DBlendFactor.ZERO, Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA ]
},
// premultiplied alpha
{
"none" : [ Context3DBlendFactor.ONE, Context3DBlendFactor.ZERO ],
"normal" : [ Context3DBlendFactor.ONE, Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA ],
"add" : [ Context3DBlendFactor.ONE, Context3DBlendFactor.ONE ],
"multiply" : [ Context3DBlendFactor.DESTINATION_COLOR, Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA ],
"screen" : [ Context3DBlendFactor.ONE, Context3DBlendFactor.ONE_MINUS_SOURCE_COLOR ],
"erase" : [ Context3DBlendFactor.ZERO, Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA ]
}
];
Isn't there any solution for 'ADD' blending instead of 'SCREEN' ? . . .
Most runtimes don't have that. You can modify SkeletonSprite to meet your needs. Eg, check the name of the slot and set the BlendMode to SCREEN.
Maybe too late, and just an idea: can the ATF textures not contain mimaps, or just blacks? And the ADD blend mode does nothing with black...
if you're using texture packer you can set "reduce border artifacts" in sprites advanced options, also pack atf without compression, I used -q 0 for best quality, it worked for me perfectly.