From cd3b9816c2b3e2dbe0fcb9dad07ea37c3d95b7fd Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 22 Mar 2021 15:15:42 +0100 Subject: [PATCH 1/4] [xna] Fixed an example shader fx compile error (occurring under some setups) at a `pow()` call. --- spine-xna/example-content/SpineEffectNormalmap.fx | 1 + 1 file changed, 1 insertion(+) diff --git a/spine-xna/example-content/SpineEffectNormalmap.fx b/spine-xna/example-content/SpineEffectNormalmap.fx index ff86b8bcb..365ef76ee 100644 --- a/spine-xna/example-content/SpineEffectNormalmap.fx +++ b/spine-xna/example-content/SpineEffectNormalmap.fx @@ -47,6 +47,7 @@ void GetLightContributionBlinnPhong(inout float3 diffuseResult, inout float3 spe diffuseResult += lightDiffuse * max(0.0, dot(normal, -lightDirection)); half3 halfVector = normalize(-lightDirection + viewDirection); float nDotH = max(0, dot(normal, halfVector)); + specularExponent = max(0.00001, specularExponent); // prevent fx compiler error at pow() below specularResult += lightSpecular * pow(nDotH, specularExponent); } From 20e6eedc163906ba11c4a432e0d32dd43f452ea1 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Tue, 23 Mar 2021 16:23:37 +0100 Subject: [PATCH 2/4] [unity] Fixed `Outline` shaders 4 and 8 neighbourhood outline thickness consistency. There was an obvious bug in the shader, dividing through the wrong number of samples. Closes #1864. --- CHANGELOG.md | 1 + .../spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c97198e7..ea29fc69a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ * `Skin.Attachments` now replaces `Skin.GetAttachments()`, returning an `ICollection`. This makes access more consistent and intuitive. To fix any compile errors, replace any occurrances of `skin.GetAttachments()` by `skin.Attachments`. * Reverted changes: `BoneFollower` property `followLocalScale` has intermediately been renamed to `followScale` but was renamed back to `followLocalScale`. Serialized values (scenes and prefabs) will automatically be upgraded, only code accessing `followScale` needs to be adapted. * Corrected blending behaviour of all `Sprite` shaders in `Premultiply Alpha` blend mode (including URP and LWRP packages). Previously vertex color alpha was premultiplied again, even though `Premultiply Alpha` blend mode assumes PMA texture and PMA vertex color input. Slot-alpha blending will thus be correctly lighter after upgrading to 4.0. If you have compensated this problem by disabling `Advanced - PMA Vertex Colors` you can now re-enable this parameter, also allowing for rendering Additive slots in a single pass. + * Corrected all `Outline` shaders outline thickness when `Advanced - Sample 8 Neighbourhood` is disabled (thus using `4 Neighbourhood`). Previously weighting was incorrectly thick (4x as thick) compared to 8 neighbourhood, now it is more consistent. This might require adjustment of all your outline materials where `Sample 8 Neighbourhood` is disabled to restore the previous outline thickness, by adjusting the `Outline Threshold` parameter through adding a `/4` to make the threshold 4 times smaller. * **Additions** * Additional **Fix Draw Order** parameter at SkeletonRenderer, defaults to `disabled` (previous behaviour). diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc index ca5b10517..2cbd874ab 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc @@ -31,7 +31,7 @@ float4 computeOutlinePixel(sampler2D mainTexture, float2 mainTextureTexelSize, pixelTopLeft + pixelTopRight + pixelBottomLeft + pixelBottomRight) * vertexColorAlpha / numSamples; #else // 4 neighbourhood - float numSamples = 1; + float numSamples = 4; float average = (pixelTop + pixelBottom + pixelLeft + pixelRight) * vertexColorAlpha / numSamples; #endif float thresholdStart = ThresholdEnd * (1.0 - OutlineSmoothness); From 1d2cad34a31cac4db09cfac22959e34cf1db48c1 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Tue, 23 Mar 2021 19:32:30 +0100 Subject: [PATCH 3/4] [unity] Fixed incorrect Timeline flip clip state when paused. Closes #1865. --- .../SpineSkeletonFlipMixerBehaviour.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs index a37b76fd1..415253f5e 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineSkeletonFlip/SpineSkeletonFlipMixerBehaviour.cs @@ -27,6 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#if UNITY_2018_1_OR_NEWER +#define PLAYABLE_DIRECTOR_HAS_STOPPED_EVENT +#endif + using System; using UnityEngine; using UnityEngine.Playables; @@ -42,6 +46,31 @@ namespace Spine.Unity.Playables { SpinePlayableHandleBase playableHandle; bool m_FirstFrameHappened; +#if PLAYABLE_DIRECTOR_HAS_STOPPED_EVENT + PlayableDirector director = null; + + public override void OnPlayableCreate (Playable playable) { + director = playable.GetGraph().GetResolver() as PlayableDirector; + if (director) + director.stopped += OnDirectorStopped; + } + + public override void OnPlayableDestroy (Playable playable) { + if (director) + director.stopped -= OnDirectorStopped; + + base.OnPlayableDestroy(playable); + } + + void OnDirectorStopped (PlayableDirector obj) { + OnStop(); + } +#else + public override void OnGraphStop (Playable playable) { + OnStop(); + } +#endif + public override void ProcessFrame (Playable playable, FrameData info, object playerData) { playableHandle = playerData as SpinePlayableHandleBase; @@ -91,7 +120,7 @@ namespace Spine.Unity.Playables { skeleton.ScaleY = flipY ? -baseScaleY : baseScaleY; } - public override void OnGraphStop (Playable playable) { + public void OnStop () { m_FirstFrameHappened = false; if (playableHandle == null) From fdd3a663efea73708c055e188cfe4dc93fd5e38d Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 24 Mar 2021 19:27:15 +0100 Subject: [PATCH 4/4] [unity] Fixed binary .skel.bytes file incorrectly being reported as .json (and import being aborted). Closes #1867. --- .../Asset Types/SkeletonDataCompatibility.cs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs index 5abf7cc10..2eb9c8c74 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs @@ -170,21 +170,13 @@ namespace Spine.Unity { string fileText = file.text; const int maxCharsToCheck = 256; int numCharsToCheck = Math.Min(fileText.Length, maxCharsToCheck); - if (fileText.IndexOf("\"skeleton\"", 0, numCharsToCheck) != -1 || - fileText.IndexOf("\"hash\"", 0, numCharsToCheck) != -1 || - fileText.IndexOf("\"spine\"", 0, numCharsToCheck) != -1) - return true; - - int jsonCharCount = 0; - const string jsonChars = "{}:\","; for (int i = 0; i < numCharsToCheck; ++i) { char c = fileText[i]; - if (jsonChars.IndexOf(c) != -1 || char.IsWhiteSpace(c)) - ++jsonCharCount; + if (char.IsWhiteSpace(c)) + continue; + return c == '{'; } - if (jsonCharCount > numCharsToCheck / 10) - return true; - return false; + return true; } public static CompatibilityProblemInfo GetCompatibilityProblemInfo (VersionInfo fileVersion) {