Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ios][libgdx]premultipliedAlpha Rendering Issue on iOS Compared to Android #2586

Open
zyvv opened this issue Jul 25, 2024 · 5 comments
Open

Comments

@zyvv
Copy link

zyvv commented Jul 25, 2024

Description

I'm encountering an issue with premultipliedAlpha rendering for Spine files when transitioning between Android and iOS platforms. On Android, enabling premultipliedAlpha correctly renders the black background as transparent. However, on iOS, the rendering does not display as expected.

Details

  • Android Behavior: The colors are rendered correctly with transparency using the following code:

    float red = r * color.r * multiplier;
    float green = g * color.g * multiplier;
    float blue = b * color.b * multiplier;
    float light = NumberUtils.intToFloatColor((int)alpha << 24 | (int)(blue * lightColor.b) << 16 | (int)(green * lightColor.g) << 8 | (int)(red * lightColor.r));
  • iOS Behavior: The iOS code differs from Android's implementation and results in incorrect rendering.

Steps to Reproduce

  1. Load the same Spine file on both Android and iOS.
  2. Enable premultipliedAlpha on both platforms.
  3. Observe the rendering differences, especially with black backgrounds.

Expected Behavior

On both platforms, the black background should be rendered as transparent when premultipliedAlpha is enabled.

Actual Behavior

The black background is correctly rendered as transparent on Android but not on iOS.

@zyvv zyvv changed the title premultipliedAlpha Rendering Issue on iOS Compared to Android [ios][libgdx]premultipliedAlpha Rendering Issue on iOS Compared to Android Jul 25, 2024
@badlogic
Copy link
Collaborator

The iOS code differs from Android's implementation and results in incorrect rendering.

What do you mean by that? The code inside spine-libgdx is the same on all platforms.

On iOS, your atlas .png files are most likely preprocessed by the MobiVM build tools (actually Xcode). Try rendering with premultipliedAlpha false on iOS. If that gives you the correct output, then the preprocessing is at fault, which you can turn off in the MobiVM configuration if I remember correctly.

@csbz17027
Copy link

I encountered the same problem!
When playing spine through libgdx on Android, the background is transparent, but when using spine-ios with the same settings on iOS, the background is black.
Anyone know why this is?

@badlogic
Copy link
Collaborator

badlogic commented Aug 5, 2024

Please show the code you use to draw that skeleton on iOS, including the SwiftUI scaffold around it with its background settings etc.

@csbz17027
Copy link

Have a solution to the problem?

@AndSwiftUs
Copy link

Help please, how to set "premultipliedAlpha" true/false on iOS to SpineView?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants