jabuwu / bevy_spine

A Bevy plugin for Spine
https://docs.rs/bevy_spine
Other
84 stars 5 forks source link

fix: handle dark_color alpha in spine shader #20

Closed dt665m closed 6 months ago

dt665m commented 6 months ago

Fix for Spine Dark Tint Rendering #18

Dark Tint Color (when set) is always shown because the Spine uses the primary color's alpha as the alpha for everything. The shader was not multiplying the dark RGB by the primary's Alpha, causing dark tint to be rendered when it shouldn't be.

This was found by digging through the Unity shaders in the official spine-runtime here

jabuwu commented 6 months ago

Good catch, it seems this is a perfect storm of three features:

That last one is part of export settings in Spine. This PR fixes the case that PMA is enabled, but breaks the case when PMA is disabled. That's why the code you added is in an ifdef in the Unity shader code.

I would like to handle both before we merge this. I believe we can do it CPU side instead of modifying the shader, same as spine-webgl where I originally pulled the shader code from.

https://github.com/EsotericSoftware/spine-runtimes/blob/5232c1cb774c0ca2510a8f4484e5f6ecd675e2ec/spine-ts/spine-webgl/src/Shader.ts#L264

dt665m commented 6 months ago

closing due to a fix in rusty_spine to do this properly in cpu