Huatimes

The alpha blend effect in spine different from the effect in unity.
eg:
I have two images, one is green with rgb(0,128,0), the other one is red with rgb()128,0,0),
and in spine i blend these two image, set the green image's alpha is 128, it looks like this:
1.png

But in unity it looks like this:
2.png


I guess the difference is in unity i change to the linear color space, but now i want to know how to solve this question. thank you.
添付ファイルを見るにはパーミッションが必要です
Huatimes
  • 記事: 9

Harald

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?
アバター
Harald

Harri
  • 記事: 1514

Huatimes

Hi, I want to find a solution that how to show same effect in spine and in unity with linear space
.

---

And now most games is using linear space, but if we use blend in spine, we will see incorrect effects in unity, we hope you give us a solution.
Our aim is see the same effect.
Huatimes
  • 記事: 9

Harald

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.
アバター
Harald

Harri
  • 記事: 1514

Huatimes

Hi, I have already sent you a email with the unity and spine projects in a zip file, please check it, thanks.
And let me describe it again.
1)I use slot color alpha to make the image have the opacity of 0.5 in spine;
1.png

2)The atlas texture import settings in unity like this:
2.png

3)The atlas export settings that I used in Spine like this:
3.png

4)The material settings in unity like this:
4.png



The unity project and spine project:
SpineTest.zip
添付ファイルを見るにはパーミッションが必要です
Huatimes
  • 記事: 9

Harald

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.
アバター
Harald

Harri
  • 記事: 1514

Huatimes

Thank you for your reply again. I've already know the cause of this problem.
Now here's the difficulty, our game project in unity must open Linear Space option, but the blending in UI not friendly, there is no good way to solve it in Spine, but in photoshop, it provides functionality to display blending in Linear color space, i want to know is there a plan to support it in spine, or do you have any good suggestions to work between in Unity and Spine with linear space.
Thank again.
Huatimes
  • 記事: 9

Harald

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
アバター
Harald

Harri
  • 記事: 1514


Return to 中国Spine用户