瀏覽代碼

Merge branch '4.0-beta' of https://github.com/esotericsoftware/spine-runtimes into 4.0-beta

badlogic 4 年之前
父節點
當前提交
be23ed8508

+ 1 - 0
CHANGELOG.md

@@ -51,6 +51,7 @@
   * `Skin.Attachments` now replaces `Skin.GetAttachments()`, returning an `ICollection<SkinEntry>`. This makes access more consistent and intuitive. To fix any compile errors, replace any occurrances of `skin.GetAttachments()` by `skin.Attachments`.
   * `Skin.Attachments` now replaces `Skin.GetAttachments()`, returning an `ICollection<SkinEntry>`. 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.
   * 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 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**
 * **Additions**
   * Additional **Fix Draw Order** parameter at SkeletonRenderer, defaults to `disabled` (previous behaviour).
   * Additional **Fix Draw Order** parameter at SkeletonRenderer, defaults to `disabled` (previous behaviour).

+ 4 - 12
spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs

@@ -170,21 +170,13 @@ namespace Spine.Unity {
 			string fileText = file.text;
 			string fileText = file.text;
 			const int maxCharsToCheck = 256;
 			const int maxCharsToCheck = 256;
 			int numCharsToCheck = Math.Min(fileText.Length, maxCharsToCheck);
 			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) {
 			for (int i = 0; i < numCharsToCheck; ++i) {
 				char c = fileText[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) {
 		public static CompatibilityProblemInfo GetCompatibilityProblemInfo (VersionInfo fileVersion) {

+ 1 - 1
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)
 		pixelTopLeft + pixelTopRight + pixelBottomLeft + pixelBottomRight)
 		* vertexColorAlpha / numSamples;
 		* vertexColorAlpha / numSamples;
 #else // 4 neighbourhood
 #else // 4 neighbourhood
-	float numSamples = 1;
+	float numSamples = 4;
 	float average = (pixelTop + pixelBottom + pixelLeft + pixelRight) * vertexColorAlpha / numSamples;
 	float average = (pixelTop + pixelBottom + pixelLeft + pixelRight) * vertexColorAlpha / numSamples;
 #endif
 #endif
 	float thresholdStart = ThresholdEnd * (1.0 - OutlineSmoothness);
 	float thresholdStart = ThresholdEnd * (1.0 - OutlineSmoothness);

+ 30 - 1
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.
  * 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 System;
 using UnityEngine;
 using UnityEngine;
 using UnityEngine.Playables;
 using UnityEngine.Playables;
@@ -42,6 +46,31 @@ namespace Spine.Unity.Playables {
 		SpinePlayableHandleBase playableHandle;
 		SpinePlayableHandleBase playableHandle;
 		bool m_FirstFrameHappened;
 		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) {
 		public override void ProcessFrame (Playable playable, FrameData info, object playerData) {
 			playableHandle = playerData as SpinePlayableHandleBase;
 			playableHandle = playerData as SpinePlayableHandleBase;
 
 
@@ -91,7 +120,7 @@ namespace Spine.Unity.Playables {
 			skeleton.ScaleY = flipY ? -baseScaleY : baseScaleY;
 			skeleton.ScaleY = flipY ? -baseScaleY : baseScaleY;
 		}
 		}
 
 
-		public override void OnGraphStop (Playable playable) {
+		public void OnStop () {
 			m_FirstFrameHappened = false;
 			m_FirstFrameHappened = false;
 
 
 			if (playableHandle == null)
 			if (playableHandle == null)

+ 1 - 0
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));
 	diffuseResult += lightDiffuse * max(0.0, dot(normal, -lightDirection));
 	half3 halfVector = normalize(-lightDirection + viewDirection);
 	half3 halfVector = normalize(-lightDirection + viewDirection);
 	float nDotH = max(0, dot(normal, halfVector));
 	float nDotH = max(0, dot(normal, halfVector));
+	specularExponent = max(0.00001, specularExponent); // prevent fx compiler error at pow() below
 	specularResult += lightSpecular * pow(nDotH, specularExponent);
 	specularResult += lightSpecular * pow(nDotH, specularExponent);
 }
 }