This commit is contained in:
badlogic 2021-03-26 12:43:31 +01:00
commit be23ed8508
5 changed files with 37 additions and 14 deletions

View File

@ -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`.
* 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).

View File

@ -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) {

View File

@ -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);

View File

@ -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)

View File

@ -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);
}