- Edited
The blend effect in spine different from unity
Do you want to know how you can switch from Linear
color space to Gamma
color space?
This can be done via Edit - Project Settings - Player
Other Settings - Rendering - Color Space
.
Or do you want to find a solution without switching color space to Gamma
?
Could you please provide more context about how your exact setup is in both Spine and in Unity?
Especially regarding the following questions:
1) Do you use slot color alpha (which ends up being vertex color alpha) to make the image have the opacity of 0.5? Or does your image already have an alpha value of 0.5 and no slot color?
2) Could you please show a screenshot of the atlas texture import settings in Unity (what the Inspector shows when the atlas png image is selected in the project panel)?
3) Could you show a screenshot of the atlas export settings that you used in Spine? Are you using the Premultiply alpha
workflow?
4) Could you please show a screenshot of the material (shader) settings in Unity? Which shader are you using?
Instead of answering all questions above, you could also send us a zip file of a minimal Unity project that shows the problem, to contact@esotericsoftware.com, mentioning the URL of this thread as reference.
Sorry for the late reply, I have been on Christmas vacation and have just returned.
Thanks for the email and the detailled description. I will get back to you as soon as I have a solution to offer.
Unfortunately the problem lies in the fundamental difference of alpha blending of two colors in Linear and in Gamma space.
Imagine you are gradually incrementing Gamma space values from 0.0 in 0.1 increments, then you will longer stay at darker values when compared to incrementing Linear space values from 0.0 in the same step size.
Alpha-blending is defined as multiplication of the color value in the target color space. Now consider your example of:
foreground = (0, 1, 0), background = (1, 0, 0) and alpha = 0.5
Note: no matter in which color space, Linear(1)==Gamma(1)
This leads to:
result = (0.5, 0.5, 0)
The problem here is that when the render settings are configured to use Linear color space, the result is finally converted to Gamma space, resulting in a very bright Gamma value of 0,73.
In other words, combining any two color values in Linear space will result in lighter values than combining them in Gamma space.
In yet other words, the problem here is that the alpha blending function is defined by the color space. If you want alpha blending in Unity to behave as in the Spine Editor (unfortunately, the Spine Editor does not yet provide functionality to display blending in Linear color space.), so that your texture values of pure green
and pure red
with alpha 0.5
result in 128 red, 128 green
, then you have to switch to Gamma space. The main reason to use Linear color space is that light is accumulated correctly and light interaction with surfaces at angles behaves more correctly in Linear space. If however you need blending to be intuitive and don't need light interaction at all different angles to behave as in the real world, Gamma space will be easier to handle. It will also save the overhead of the two conversions from Gamma space to Linear space and back again.
We are very sorry for the late reply. We had a larger discussion about the whole colorspace topic, also based on display problems reported on wide color gamut monitors. As a result, we decided that it will be necessary to first perform tests in order to find a good and reliable solution working across different devices and then integrate this solution in Spine. When the colorspace conversion pipeline is set up and working reliably, we could then finally integrate different alpha blend modes on top as well.
This is the issue ticket used for the topic: https://github.com/EsotericSoftware/spine-editor/issues/537