From 5937b3021b21aa5c06b888a41bb9dfd315421a42 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 11 Oct 2021 18:24:24 +0200 Subject: [PATCH 1/6] [unity] Fixed Timeline clip not updating to the shown EaseIn & MixerBehaviour when inside Play mode. Added null check. Closes #1962. --- .../Editor/SpineAnimationStateDrawer.cs | 7 ++++++- .../SpineAnimationStateBehaviour.cs | 3 +++ .../SpineAnimationStateClip.cs | 3 +++ .../SpineAnimationStateMixerBehaviour.cs | 17 ++++++++++++++--- .../SpineAnimationStateTrack.cs | 8 ++++++++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs index 931fc3583..268d60848 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Editor/SpineAnimationStateDrawer.cs @@ -109,7 +109,12 @@ public class SpineAnimationStateDrawer : PropertyDrawer { EditorGUI.PropertyField(singleFieldRect, useBlendDurationProp); singleFieldRect.y += lineHeightWithSpacing; - EditorGUI.PropertyField(singleFieldRect, mixDurationProp); + + bool greyOutMixDuration = (!useBlendDurationProp.hasMultipleDifferentValues && + useBlendDurationProp.boolValue == true); + using (new EditorGUI.DisabledGroupScope(greyOutMixDuration)) { + EditorGUI.PropertyField(singleFieldRect, mixDurationProp); + } } singleFieldRect.y += lineHeightWithSpacing; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs index c5dd632f9..0e76688b2 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateBehaviour.cs @@ -41,6 +41,9 @@ namespace Spine.Unity.Playables { [Serializable] public class SpineAnimationStateBehaviour : PlayableBehaviour { + + [NonSerialized] public TimelineClip timelineClip; + public AnimationReferenceAsset animationReference; public bool loop; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateClip.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateClip.cs index 0ab9b18f4..13121c1f5 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateClip.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateClip.cs @@ -38,8 +38,11 @@ namespace Spine.Unity.Playables { public SpineAnimationStateBehaviour template = new SpineAnimationStateBehaviour(); public ClipCaps clipCaps { get { return ClipCaps.Blending | ClipCaps.ClipIn | ClipCaps.SpeedMultiplier | (template.loop ? ClipCaps.Looping : 0); } } + [NonSerialized] public TimelineClip timelineClip; public override Playable CreatePlayable (PlayableGraph graph, GameObject owner) { + template.timelineClip = this.timelineClip; + var playable = ScriptPlayable.Create(graph, template); playable.GetBehaviour(); return playable; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs index aa9fa5086..0bfae9f15 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs @@ -95,6 +95,8 @@ namespace Spine.Unity.Playables { } protected void HandleClipEnd () { + if (animationStateComponent == null) return; + var state = animationStateComponent.AnimationState; if (endAtClipEnd && timelineStartedTrackEntry != null && @@ -172,13 +174,14 @@ namespace Spine.Unity.Playables { endMixOutDuration = clipData.endMixOutDuration; if (clipData.animationReference == null) { - float mixDuration = clipData.customDuration ? clipData.mixDuration : state.Data.DefaultMix; + float mixDuration = clipData.customDuration ? GetCustomMixDuration(clipData) : state.Data.DefaultMix; state.SetEmptyAnimation(trackIndex, mixDuration); } else { if (clipData.animationReference.Animation != null) { TrackEntry currentEntry = state.GetCurrent(trackIndex); Spine.TrackEntry trackEntry; - if (currentEntry == null && (clipData.customDuration && clipData.mixDuration > 0)) { + float customMixDuration = clipData.customDuration ? GetCustomMixDuration(clipData) : 0.0f; + if (currentEntry == null && customMixDuration > 0) { state.SetEmptyAnimation(trackIndex, 0); // ease in requires empty animation trackEntry = state.AddAnimation(trackIndex, clipData.animationReference.Animation, clipData.loop, 0); } else @@ -192,7 +195,7 @@ namespace Spine.Unity.Playables { trackEntry.HoldPrevious = clipData.holdPrevious; if (clipData.customDuration) - trackEntry.MixDuration = clipData.mixDuration; + trackEntry.MixDuration = customMixDuration; timelineStartedTrackEntry = trackEntry; } @@ -314,6 +317,14 @@ namespace Spine.Unity.Playables { } #endif + float GetCustomMixDuration (SpineAnimationStateBehaviour clipData) { + if (clipData.useBlendDuration) { + TimelineClip clip = clipData.timelineClip; + return (float)Math.Max(clip.blendInDuration, clip.easeInDuration); + } else { + return clipData.mixDuration; + } + } } } diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateTrack.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateTrack.cs index 4165d5bba..502234ee9 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateTrack.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateTrack.cs @@ -27,6 +27,7 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +using System.Collections.Generic; using UnityEngine; using UnityEngine.Playables; using UnityEngine.Timeline; @@ -39,6 +40,13 @@ namespace Spine.Unity.Playables { public int trackIndex = 0; public override Playable CreateTrackMixer (PlayableGraph graph, GameObject go, int inputCount) { + IEnumerable clips = this.GetClips(); + foreach (TimelineClip clip in clips) { + var animationStateClip = clip.asset as SpineAnimationStateClip; + if (animationStateClip != null) + animationStateClip.timelineClip = clip; + } + var scriptPlayable = ScriptPlayable.Create(graph, inputCount); var mixerBehaviour = scriptPlayable.GetBehaviour(); mixerBehaviour.trackIndex = this.trackIndex; From 43e8000c80441d327252ac163c30aef486a52933 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Tue, 12 Oct 2021 12:48:49 +0200 Subject: [PATCH 2/6] [unity] Fixed URP Sprite shader ignoring `Fixed normal` in some settings. Closes #1967. Fixed a warning. --- .../Spine-Sprite-StandardPass-URP-2D.hlsl | 2 +- .../Include/Spine-Sprite-ForwardPass-URP.hlsl | 22 ++++--------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl index 8205b357a..c30493218 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Include/Spine-Sprite-StandardPass-URP-2D.hlsl @@ -104,7 +104,7 @@ half4 CombinedShapeLightFragment(VertexOutputSpriteURP2D input) : SV_Target pixel.rgb = applyRimLighting(input.positionWS.xyz, normalWS, pixel); #endif - APPLY_EMISSION(pixel.rgb, input.texcoord) + APPLY_EMISSION(pixel.rgb, input.texcoord.xy) pixel = prepareLitPixelForOutput(pixel, texureColor.a, input.vertexColor.a); COLORISE(pixel) return pixel; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl index 0de40b54f..7c39640cd 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl @@ -127,7 +127,7 @@ half4 LightweightFragmentBlinnPhongSimplified(InputData inputData, half4 texDiff #endif half3 diffuseLighting = inputData.bakedGI; - half3 attenuation = mainLight.distanceAttenuation * mainLight.shadowAttenuation; + half3 attenuation = mainLight.distanceAttenuation* mainLight.shadowAttenuation; half3 attenuatedLightColor = mainLight.color * attenuation; #ifndef _DIFFUSE_RAMP diffuseLighting += LightingLambert(attenuatedLightColor, mainLight.direction, inputData.normalWS); @@ -184,24 +184,15 @@ VertexOutputLWRP ForwardPassVertexSprite(VertexInput input) output.positionWS = float4(positionWS, 1); #endif -#if defined(PER_PIXEL_LIGHTING) - half3 normalWS = calculateSpriteWorldNormal(input, -backFaceSign); output.normalWorld.xyz = normalWS; - #if defined(_NORMALMAP) output.tangentWorld.xyz = calculateWorldTangent(input.tangent); output.binormalWorld.xyz = calculateSpriteWorldBinormal(input, output.normalWorld.xyz, output.tangentWorld.xyz, backFaceSign); #endif -#else // !PER_PIXEL_LIGHTING - half3 fixedNormal = half3(0, 0, -1); - half3 normalWS = normalize(mul((float3x3)unity_ObjectToWorld, fixedNormal)); - -#endif // !PER_PIXEL_LIGHTING output.fogFactorAndVertexLight.yzw = LightweightLightVertexSimplified(positionWS, normalWS); - #if (defined(_MAIN_LIGHT_SHADOWS) || defined(MAIN_LIGHT_CALCULATE_SHADOWS)) && !defined(_RECEIVE_SHADOWS_OFF) VertexPositionInputs vertexInput; vertexInput.positionWS = positionWS; @@ -243,16 +234,11 @@ half4 ForwardPassFragmentSprite(VertexOutputLWRP input) : SV_Target inputData.viewDirectionWS = input.viewDirectionWS; inputData.vertexLighting = input.fogFactorAndVertexLight.yzw; -#if defined(PER_PIXEL_LIGHTING) - #if defined(_NORMALMAP) +#if defined(PER_PIXEL_LIGHTING) && defined(_NORMALMAP) half3 normalWS = calculateNormalFromBumpMap(input.texcoord.xy, input.tangentWorld.xyz, input.binormalWorld.xyz, input.normalWorld.xyz); - #else +#else half3 normalWS = input.normalWorld.xyz; - #endif -#else // !PER_PIXEL_LIGHTING - half3 fixedNormal = half3(0, 0, -1); - half3 normalWS = normalize(mul((float3x3)unity_ObjectToWorld, fixedNormal)); -#endif // !PER_PIXEL_LIGHTING +#endif inputData.normalWS = normalWS; inputData.bakedGI = SAMPLE_GI(input.lightmapUV, input.vertexSH, inputData.normalWS); From 947da83533d315fb463472a04558c5a30e009ae9 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Tue, 12 Oct 2021 12:50:02 +0200 Subject: [PATCH 3/6] [unity] Increased package version number of last commit's changes. See #1967, commit 43e8000. --- .../Modules/com.esotericsoftware.spine.urp-shaders/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json index 5df14a0ca..2fe826886 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.urp-shaders", "displayName": "Spine Universal RP Shaders", "description": "This plugin provides universal render pipeline (URP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.0.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "4.0.4", + "version": "4.0.5", "unity": "2019.3", "author": { "name": "Esoteric Software", From 308da950df4d75da1bf17ddc5c5dfc09a139e063 Mon Sep 17 00:00:00 2001 From: badlogic Date: Wed, 13 Oct 2021 15:24:28 +0200 Subject: [PATCH 4/6] [ts] Fixed test-drawcalls asset paths. --- spine-ts/spine-webgl/tests/test-drawcalls.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spine-ts/spine-webgl/tests/test-drawcalls.html b/spine-ts/spine-webgl/tests/test-drawcalls.html index 5b66ee5a8..769b18846 100644 --- a/spine-ts/spine-webgl/tests/test-drawcalls.html +++ b/spine-ts/spine-webgl/tests/test-drawcalls.html @@ -21,7 +21,7 @@ info; loadAssets(canvas) { - this.numSkeletons = 100; + this.numSkeletons = 400; this.skeletons = []; this.states = []; this.info = document.querySelector("#info")[0]; @@ -45,7 +45,7 @@ for (var i = 0; i < this.numSkeletons; i++) { let skeleton = new spine.Skeleton(skeletonData); - // Create the animation state + // Create the animation state let state = new spine.AnimationState(stateData); state.setAnimation(0, "dance", true); @@ -92,13 +92,13 @@ renderer.drawSkeleton(skeleton, true); } renderer.end(); - info.innerText = "Draw calls: " + renderer.batcher.drawCalls; + info.innerText = "Draw calls: " + renderer.batcher.drawCalls + ", FPS: " + canvas.time.framesPerSecond.toFixed(0); } } // Create the Spine canvas which runs the app new spine.SpineCanvas(document.getElementById("canvas"), { - pathPrefix: "assets/", + pathPrefix: "../example/assets/", app: new App() }); From caed7614c83a55e0002fc8d7f0279158274d916e Mon Sep 17 00:00:00 2001 From: badlogic Date: Tue, 19 Oct 2021 22:11:31 +0200 Subject: [PATCH 5/6] [ue4] Update example project to UE 4.27 --- CHANGELOG.md | 2 +- spine-ue4/SpineUE4.uproject | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29672da9f..2f256797f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,7 +63,7 @@ * Generated normals are now correctly flipped for back faces. * Modifying parent materials updates material instances accordingly. * Only `.json` files that are actually encoding Spine skeletons will be loaded. Other `.json` files will be left to other importers. -* Updated example project to UE 4.25. +* Updated example project to UE 4.27. ## C# ## diff --git a/spine-ue4/SpineUE4.uproject b/spine-ue4/SpineUE4.uproject index bdda1211f..05d782f11 100644 --- a/spine-ue4/SpineUE4.uproject +++ b/spine-ue4/SpineUE4.uproject @@ -1,6 +1,6 @@ { "FileVersion": 3, - "EngineAssociation": "4.25", + "EngineAssociation": "4.27", "Category": "", "Description": "", "Modules": [ From 38cc19f16d796b0a59a9aba3dc56f2e7debe9332 Mon Sep 17 00:00:00 2001 From: badlogic Date: Wed, 20 Oct 2021 00:09:31 +0200 Subject: [PATCH 6/6] [ts][threejs] Added multi-page atlas and blend modes support Also updated to latest ThreeJS release and some clean-up. --- spine-ts/package-lock.json | 32 ++++---- spine-ts/spine-threejs/example/index.html | 1 - spine-ts/spine-threejs/package.json | 6 +- spine-ts/spine-threejs/src/MeshBatcher.ts | 78 ++++++++++++++++++- spine-ts/spine-threejs/src/SkeletonMesh.ts | 81 ++++++++------------ spine-ts/spine-threejs/src/ThreeJsTexture.ts | 24 ++++-- 6 files changed, 140 insertions(+), 82 deletions(-) diff --git a/spine-ts/package-lock.json b/spine-ts/package-lock.json index 4f931ba73..9080dadca 100644 --- a/spine-ts/package-lock.json +++ b/spine-ts/package-lock.json @@ -156,9 +156,9 @@ "dev": true }, "node_modules/@types/three": { - "version": "0.131.1", - "resolved": "https://registry.npmjs.org/@types/three/-/three-0.131.1.tgz", - "integrity": "sha512-unnjsolcm7R90e4XK9qMq4JYEzly0XQNa0pG8RAOMZeVzj3FLIFPymAYUx4Osz0gY9jFZz8omIQplqiieEE7gw==" + "version": "0.133.1", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.133.1.tgz", + "integrity": "sha512-XqBrP/+kbs+o0CYRhCVVE95v7FaL2bO5Z7+3VQJE0nEyjo+9LoLfeNgZITOnndKHxM+7ltEciAIR7uE0SZlsOg==" }, "node_modules/accepts": { "version": "1.3.7", @@ -7838,9 +7838,9 @@ } }, "node_modules/three": { - "version": "0.132.2", - "resolved": "https://registry.npmjs.org/three/-/three-0.132.2.tgz", - "integrity": "sha512-0wcR7LxxkXMn6Gi58gEs3QvY8WpTVXA31L2VOvpjm4ZPYFRHCZC13UqynheFoS5OXDYgtBneN0dhbaNBE8iLhQ==" + "version": "0.133.1", + "resolved": "https://registry.npmjs.org/three/-/three-0.133.1.tgz", + "integrity": "sha512-WydohO8ll949B0FTD6MGz59Yv2Lwj8hvObg/0Heh2r42S6+tQC1WByfCNRdmG4D7+odfGod+n8JPV1I2xrboWw==" }, "node_modules/through": { "version": "2.3.8", @@ -8280,8 +8280,8 @@ "license": "LicenseRef-LICENSE", "dependencies": { "@esotericsoftware/spine-core": "^4.0.13", - "@types/three": "^0.131.0", - "three": "^0.132.0" + "@types/three": "^0.133.1", + "three": "^0.133.1" } }, "spine-webgl": { @@ -8391,8 +8391,8 @@ "version": "file:spine-threejs", "requires": { "@esotericsoftware/spine-core": "^4.0.13", - "@types/three": "^0.131.0", - "three": "^0.132.0" + "@types/three": "^0.133.1", + "three": "^0.133.1" } }, "@esotericsoftware/spine-webgl": { @@ -8414,9 +8414,9 @@ "dev": true }, "@types/three": { - "version": "0.131.1", - "resolved": "https://registry.npmjs.org/@types/three/-/three-0.131.1.tgz", - "integrity": "sha512-unnjsolcm7R90e4XK9qMq4JYEzly0XQNa0pG8RAOMZeVzj3FLIFPymAYUx4Osz0gY9jFZz8omIQplqiieEE7gw==" + "version": "0.133.1", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.133.1.tgz", + "integrity": "sha512-XqBrP/+kbs+o0CYRhCVVE95v7FaL2bO5Z7+3VQJE0nEyjo+9LoLfeNgZITOnndKHxM+7ltEciAIR7uE0SZlsOg==" }, "accepts": { "version": "1.3.7", @@ -14486,9 +14486,9 @@ } }, "three": { - "version": "0.132.2", - "resolved": "https://registry.npmjs.org/three/-/three-0.132.2.tgz", - "integrity": "sha512-0wcR7LxxkXMn6Gi58gEs3QvY8WpTVXA31L2VOvpjm4ZPYFRHCZC13UqynheFoS5OXDYgtBneN0dhbaNBE8iLhQ==" + "version": "0.133.1", + "resolved": "https://registry.npmjs.org/three/-/three-0.133.1.tgz", + "integrity": "sha512-WydohO8ll949B0FTD6MGz59Yv2Lwj8hvObg/0Heh2r42S6+tQC1WByfCNRdmG4D7+odfGod+n8JPV1I2xrboWw==" }, "through": { "version": "2.3.8", diff --git a/spine-ts/spine-threejs/example/index.html b/spine-ts/spine-threejs/example/index.html index 63d760a1b..ca632b15d 100644 --- a/spine-ts/spine-threejs/example/index.html +++ b/spine-ts/spine-threejs/example/index.html @@ -5,7 +5,6 @@ spine-threejs -