mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
Merge remote-tracking branch 'origin/3.6-beta' into 3.6-beta
This commit is contained in:
commit
3b6b0f52e2
@ -97,6 +97,7 @@
|
||||
* **Spine folder**. In the unitypackage, the "spine-csharp" and "spine-unity" folders are now inside a "Spine" folder. This change will only affect fresh imports. Importing the unitypackage to update Spine-Unity in your existing project will update the appropriate files however you chose to arrange them, as long as the meta files are intact.
|
||||
* **Breaking changes**
|
||||
* The Sprite shaders module was updated to the latest version from the [source](https://github.com/traggett/UnitySpriteShaders/commits/master). Some changes were made to the underlying keyword structure. You may need to review the settings of your lit materials. Particularly, your Fixed Normals settings.
|
||||
* The `Spine/Skeleton Lit` shader was switched over to non-fixed-function code. It now no longer requires mesh normals and has fixed normals at the shader level.
|
||||
* The old MeshGenerator classes, interfaces and code in `Spine.Unity.MeshGeneration` are now deprecated. All mesh-generating components now share the class `Spine.Unity.MeshGenerator` defined in `SpineMesh.cs`. MeshGenerator is a serializable class.
|
||||
* The `SkeletonRenderer.renderMeshes` optimization is currently non-functional.
|
||||
* Old triangle-winding code has been removed from `SkeletonRenderer`. Please use shaders that have backface culling off.
|
||||
|
||||
@ -236,8 +236,8 @@ void spAnimationState_dispose (spAnimationState* self) {
|
||||
_spEventQueue_free(internal->queue);
|
||||
FREE(internal->events);
|
||||
FREE(internal->propertyIDs);
|
||||
FREE(internal);
|
||||
spTrackEntryArray_dispose(self->mixingTo);
|
||||
FREE(internal);
|
||||
}
|
||||
|
||||
void spAnimationState_update (spAnimationState* self, float delta) {
|
||||
|
||||
@ -589,7 +589,8 @@ namespace Spine.Unity.Editor {
|
||||
imagePaths.Add(str);
|
||||
break;
|
||||
case ".json":
|
||||
if (IsSpineData((TextAsset)AssetDatabase.LoadAssetAtPath(str, typeof(TextAsset))))
|
||||
var jsonAsset = (TextAsset)AssetDatabase.LoadAssetAtPath(str, typeof(TextAsset));
|
||||
if (jsonAsset != null && IsSpineData(jsonAsset))
|
||||
skeletonPaths.Add(str);
|
||||
break;
|
||||
case ".bytes":
|
||||
@ -1215,6 +1216,8 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
|
||||
public static bool IsSpineData (TextAsset asset) {
|
||||
if (asset == null) return false;
|
||||
|
||||
bool isSpineData = false;
|
||||
string rawVersion = null;
|
||||
|
||||
|
||||
@ -107,12 +107,12 @@ namespace Spine.Unity {
|
||||
}
|
||||
}
|
||||
|
||||
const float BoundsMinDefault = float.MaxValue;
|
||||
const float BoundsMaxDefault = float.MinValue;
|
||||
const float BoundsMinDefault = float.PositiveInfinity;
|
||||
const float BoundsMaxDefault = float.NegativeInfinity;
|
||||
|
||||
[NonSerialized] readonly ExposedList<Vector3> vertexBuffer = new ExposedList<Vector3>();
|
||||
[NonSerialized] readonly ExposedList<Vector2> uvBuffer = new ExposedList<Vector2>();
|
||||
[NonSerialized] readonly ExposedList<Color32> colorBuffer = new ExposedList<Color32>();
|
||||
[NonSerialized] readonly ExposedList<Vector3> vertexBuffer = new ExposedList<Vector3>(4);
|
||||
[NonSerialized] readonly ExposedList<Vector2> uvBuffer = new ExposedList<Vector2>(4);
|
||||
[NonSerialized] readonly ExposedList<Color32> colorBuffer = new ExposedList<Color32>(4);
|
||||
[NonSerialized] readonly ExposedList<ExposedList<int>> submeshes = new ExposedList<ExposedList<int>> { new ExposedList<int>(6) }; // start with 1 submesh.
|
||||
|
||||
[NonSerialized] Vector2 meshBoundsMin, meshBoundsMax;
|
||||
@ -940,7 +940,7 @@ namespace Spine.Unity {
|
||||
mesh.uv = ubi;
|
||||
mesh.colors32 = cbi;
|
||||
|
||||
if (meshBoundsMin.x == BoundsMinDefault) {
|
||||
if (float.IsInfinity(meshBoundsMin.x)) { // meshBoundsMin.x == BoundsMinDefault // == doesn't work on float Infinity constants.
|
||||
mesh.bounds = new Bounds();
|
||||
} else {
|
||||
//mesh.bounds = ArraysMeshGenerator.ToBounds(meshBoundsMin, meshBoundsMax);
|
||||
|
||||
@ -61,7 +61,7 @@ Shader "Spine/Skeleton Tint Black" {
|
||||
|
||||
float4 frag (VertexOutput i) : COLOR {
|
||||
float4 texColor = tex2D(_MainTex, i.uv);
|
||||
return (texColor * i.vertexColor) + float4(((1-texColor.rgb) * texColor.a * (_Black.rgb + float3(i.uv1.r, i.uv1.g, i.uv2.r))), 1);
|
||||
return (texColor * i.vertexColor) + float4(((1-texColor.rgb) * texColor.a * (_Black.rgb + float3(i.uv1.r, i.uv1.g, i.uv2.r))), 0);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Shader "Spine/Skeleton" {
|
||||
Properties {
|
||||
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[NoScaleOffset] _MainTex ("Texture to blend", 2D) = "black" {}
|
||||
[NoScaleOffset] _MainTex ("Main Texture", 2D) = "black" {}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
Shader "Spine/Skeleton Lit" {
|
||||
// - Vertex Lit + ShadowCaster
|
||||
// - Premultiplied Alpha Blending (One OneMinusSrcAlpha)
|
||||
// - Double-sided, no depth
|
||||
|
||||
Shader "Spine/Skeleton Lit" {
|
||||
Properties {
|
||||
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[NoScaleOffset] _MainTex ("Texture to blend", 2D) = "black" {}
|
||||
[NoScaleOffset] _MainTex ("Main Texture", 2D) = "black" {}
|
||||
}
|
||||
// 2 texture stage GPUs
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
@ -12,14 +16,132 @@
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
|
||||
// Pass {
|
||||
// Tags { "LightMode"="Vertex" }
|
||||
// ColorMaterial AmbientAndDiffuse
|
||||
// Lighting On
|
||||
// SetTexture [_MainTex] {
|
||||
// Combine texture * primary DOUBLE, texture * primary
|
||||
// }
|
||||
// }
|
||||
|
||||
Pass {
|
||||
Tags { "LightMode"="Vertex" }
|
||||
ColorMaterial AmbientAndDiffuse
|
||||
Lighting On
|
||||
SetTexture [_MainTex] {
|
||||
Combine texture * primary DOUBLE, texture * primary
|
||||
Tags {
|
||||
"LIGHTMODE"="Vertex"
|
||||
"QUEUE"="Transparent"
|
||||
"IGNOREPROJECTOR"="true"
|
||||
"RenderType"="Transparent"
|
||||
}
|
||||
}
|
||||
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
// ES2.0/WebGL/3DS can not do loops with non-constant-expression iteration counts :(
|
||||
#if defined(SHADER_API_GLES)
|
||||
#define LIGHT_LOOP_LIMIT 8
|
||||
#elif defined(SHADER_API_N3DS)
|
||||
#define LIGHT_LOOP_LIMIT 4
|
||||
#else
|
||||
#define LIGHT_LOOP_LIMIT unity_VertexLightParams.x
|
||||
#endif
|
||||
|
||||
#pragma multi_compile __ POINT SPOT
|
||||
|
||||
half3 computeLighting (int idx, half3 dirToLight, half3 eyeNormal, half3 viewDir, half4 diffuseColor, half atten) {
|
||||
half NdotL = max(dot(eyeNormal, dirToLight), 0.0);
|
||||
// diffuse
|
||||
half3 color = NdotL * diffuseColor.rgb * unity_LightColor[idx].rgb;
|
||||
return color * atten;
|
||||
}
|
||||
|
||||
half3 computeOneLight (int idx, float3 eyePosition, half3 eyeNormal, half3 viewDir, half4 diffuseColor) {
|
||||
float3 dirToLight = unity_LightPosition[idx].xyz;
|
||||
half att = 1.0;
|
||||
|
||||
#if defined(POINT) || defined(SPOT)
|
||||
dirToLight -= eyePosition * unity_LightPosition[idx].w;
|
||||
|
||||
// distance attenuation
|
||||
float distSqr = dot(dirToLight, dirToLight);
|
||||
att /= (1.0 + unity_LightAtten[idx].z * distSqr);
|
||||
if (unity_LightPosition[idx].w != 0 && distSqr > unity_LightAtten[idx].w) att = 0.0; // set to 0 if outside of range
|
||||
distSqr = max(distSqr, 0.000001); // don't produce NaNs if some vertex position overlaps with the light
|
||||
dirToLight *= rsqrt(distSqr);
|
||||
#if defined(SPOT)
|
||||
|
||||
// spot angle attenuation
|
||||
half rho = max(dot(dirToLight, unity_SpotDirection[idx].xyz), 0.0);
|
||||
half spotAtt = (rho - unity_LightAtten[idx].x) * unity_LightAtten[idx].y;
|
||||
att *= saturate(spotAtt);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
att *= 0.5; // passed in light colors are 2x brighter than what used to be in FFP
|
||||
return min (computeLighting (idx, dirToLight, eyeNormal, viewDir, diffuseColor, att), 1.0);
|
||||
}
|
||||
|
||||
int4 unity_VertexLightParams; // x: light count, y: zero, z: one (y/z needed by d3d9 vs loop instruction)
|
||||
|
||||
struct appdata {
|
||||
float3 pos : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
half4 color : COLOR;
|
||||
float3 uv0 : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
fixed4 color : COLOR0;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float4 pos : SV_POSITION;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
VertexOutput vert (appdata v) {
|
||||
VertexOutput o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
half4 color = v.color;
|
||||
float3 eyePos = UnityObjectToViewPos(float4(v.pos, 1)).xyz; //mul(UNITY_MATRIX_MV, float4(v.pos,1)).xyz;
|
||||
half3 fixedNormal = half3(0,0,-1);
|
||||
half3 eyeNormal = normalize(mul((float3x3)UNITY_MATRIX_IT_MV, fixedNormal));
|
||||
half3 viewDir = 0.0;
|
||||
|
||||
// Lights
|
||||
half3 lcolor = half4(0,0,0,1).rgb + color.rgb * glstate_lightmodel_ambient.rgb;
|
||||
for (int il = 0; il < LIGHT_LOOP_LIMIT; ++il) {
|
||||
lcolor += computeOneLight(il, eyePos, eyeNormal, viewDir, color);
|
||||
}
|
||||
|
||||
color.rgb = lcolor.rgb;
|
||||
o.color = saturate(color);
|
||||
o.uv0 = v.uv0;
|
||||
o.pos = UnityObjectToClipPos(v.pos);
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
fixed4 frag (VertexOutput i) : SV_Target {
|
||||
fixed4 tex = tex2D(_MainTex, i.uv0);
|
||||
|
||||
fixed4 col;
|
||||
col.rgb = tex * i.color;
|
||||
col *= 2;
|
||||
col.a = tex.a * i.color.a;
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Caster"
|
||||
@ -63,22 +185,4 @@
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
// 1 texture stage GPUs
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
|
||||
Pass {
|
||||
Tags { "LightMode"="Vertex" }
|
||||
ColorMaterial AmbientAndDiffuse
|
||||
Lighting On
|
||||
SetTexture [_MainTex] {
|
||||
Combine texture * primary DOUBLE, texture * primary
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user