mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[unity] Fixed SkeletonGraphic shader flickering on low alpha vertex colors in Linear color space. Closes #2128.
This commit is contained in:
parent
246e5a039b
commit
2b28510acd
@ -39,4 +39,18 @@ inline half4 PMAGammaToTargetSpace(half4 gammaPMAColor) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// Saturated version to prevent numerical issues that occur at CanvasRenderer
|
||||
// shader during linear-space PMA vertex color correction (countering automatic Unity conversion).
|
||||
// Note: Only use this method when the original color.rgb values lie within [0,1] range and
|
||||
// it's not an HDR color. This method is usually suitable for vertex color.
|
||||
inline half4 PMAGammaToTargetSpaceSaturated(half4 gammaPMAColor) {
|
||||
#if UNITY_COLORSPACE_GAMMA
|
||||
return gammaPMAColor;
|
||||
#else
|
||||
return gammaPMAColor.a == 0 ?
|
||||
half4(GammaToLinearSpace(gammaPMAColor.rgb), gammaPMAColor.a) :
|
||||
half4(saturate(GammaToLinearSpace(gammaPMAColor.rgb / gammaPMAColor.a)) * gammaPMAColor.a, gammaPMAColor.a);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -49,7 +49,8 @@ VertexOutput vert (VertexInput IN) {
|
||||
#else
|
||||
// Note: CanvasRenderer performs a GammaToTargetSpace conversion on vertex color already,
|
||||
// however incorrectly assuming straight alpha color.
|
||||
float4 vertexColor = PMAGammaToTargetSpace(half4(TargetToGammaSpace(IN.color.rgb), IN.color.a));
|
||||
// Saturated version used to prevent numerical issues of certain low-alpha values.
|
||||
float4 vertexColor = PMAGammaToTargetSpaceSaturated(half4(TargetToGammaSpace(IN.color.rgb), IN.color.a));
|
||||
#endif
|
||||
OUT.color = vertexColor * float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
|
||||
return OUT;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user