diff --git a/CHANGELOG.md b/CHANGELOG.md index e65c3cb1a..26606ba6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -155,6 +155,7 @@ `SkeletonGraphic-PMATexture` containing materials for premultiplied-alpha texture workflow (`Straight Alpha Texture` disabled) and `SkeletonGraphic-StaightAlphaTexture` containing materials for straight alpha texture workflow (`Straight Alpha Texture` enabled). These directories contain a set of materials with `CanvasGroup Compatible` disabled for usage with `Advanced - PMA Vertex Color` enabled at the component. Each directory also provides a subdirectory `CanvasGroupCompatible` with materials with `CanvasGroup Compatible` enabled for usage with `CanvasGroup` alpha (requiring `Advanced - PMA Vertex Color` disabled at the component). - SkeletonGraphic: Added auto-detect functionality for parameters `Advanced` - `Tint Black`, `CanvasGroup Compatible` and `PMA Vertex Color`. If unsure which settings are correct, hit the `Detect` button next to each parameter, in top to bottom order, or the `Detect Settings` to detect all three. Also added automatic material assignment via a `Detect Material` button in the `Advanced` section and a `Detect` button next to the `Material` property at the top of the component Inspector, as well as next to the `Blend Mode Materials` section when using multiple canvas renderers with blend modes. The suitable material is selected based on these three settings, combined with texture settings (PMA or straight alpha texture settings). If you receive incorrect results, likely your texture settings are incorrectly setup for your PMA or Straight alpha texture export settings. - `SkeletonRenderTexture` example components now provide a `shaderPasses` parameter to customize which passes are rendered to the `RenderTexture`. It defaults to `-1` for all passes to keep the existing behaviour. You might want to set it to `0` to only render the first pass e.g. to avoid issues when using a URP shader at the original skeleton. + - `SkeletonGraphicRenderTexture` example component now also received a `quadMaterial` property, defaulting to the newly added Material asset `RenderQuadGraphicMaterial` which applies proper premultiplied-alpha blending of the render texture. The `quadMaterial` member variable was moved from `SkeletonRenderTexture` to the common base class `SkeletonRenderTextureBase`. - **Breaking changes** diff --git a/spine-unity/Assets/Spine Examples/Other Examples/RenderTexture FadeOut Transparency.unity b/spine-unity/Assets/Spine Examples/Other Examples/RenderTexture FadeOut Transparency.unity index 93acf07d8..596dd690e 100644 --- a/spine-unity/Assets/Spine Examples/Other Examples/RenderTexture FadeOut Transparency.unity +++ b/spine-unity/Assets/Spine Examples/Other Examples/RenderTexture FadeOut Transparency.unity @@ -151,6 +151,7 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 592567554} m_RootOrder: 1 @@ -256,6 +257,9 @@ MonoBehaviour: materialsInsideMask: [] materialsOutsideMask: [] disableRenderingOnOverride: 1 + physicsPositionInheritanceFactor: {x: 1, y: 1} + physicsRotationInheritanceFactor: 1 + physicsMovementRelativeTo: {fileID: 0} updateTiming: 1 unscaledTime: 0 _animationName: run @@ -272,6 +276,7 @@ MeshRenderer: m_CastShadows: 1 m_ReceiveShadows: 1 m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 m_MotionVectors: 1 m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 @@ -320,6 +325,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -7.83, y: 0, z: 5.66} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 3 @@ -352,6 +358,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 592567554} m_RootOrder: 2 @@ -434,6 +441,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0, y: 0, z: 0} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1911967440} - {fileID: 71621967} @@ -489,6 +497,7 @@ Canvas: m_OverridePixelPerfect: 0 m_SortingBucketNormalizedSize: 0 m_AdditionalShaderChannelsFlag: 0 + m_UpdateRectTransformForStandalone: 0 m_SortingLayerID: 0 m_SortingOrder: 0 m_TargetDisplay: 0 @@ -518,6 +527,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1911967440} m_RootOrder: 0 @@ -554,6 +564,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -3.7153435, y: -0.0017910004, z: 5.9292965} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 2 @@ -583,6 +594,7 @@ GameObject: m_Component: - component: {fileID: 1369381601} - component: {fileID: 1369381600} + - component: {fileID: 1369381602} m_Layer: 0 m_Name: Directional Light m_TagString: Untagged @@ -662,10 +674,31 @@ Transform: m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalPosition: {x: 0, y: 3, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!114 &1369381602 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1369381599} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Version: 1 + m_UsePipelineSettings: 1 + m_AdditionalLightsShadowResolutionTier: 2 + m_LightLayerMask: 1 + m_CustomShadowLayers: 0 + m_ShadowLayerMask: 1 + m_LightCookieSize: {x: 1, y: 1} + m_LightCookieOffset: {x: 0, y: 0} --- !u!1 &1407691187 GameObject: m_ObjectHideFlags: 0 @@ -745,6 +778,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 4.8, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 @@ -811,6 +845,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 5 @@ -843,6 +878,7 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 592567554} m_RootOrder: 3 @@ -930,6 +966,7 @@ RectTransform: m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 592567554} m_RootOrder: 4 @@ -1019,9 +1056,10 @@ MonoBehaviour: color: {r: 1, g: 1, b: 1, a: 1} maxRenderTextureSize: 1024 quad: {fileID: 0} + quadMaterial: {fileID: 2100000, guid: 4c507f887c6274a44a603d96e0eabf2a, type: 2} renderTexture: {fileID: 0} targetCamera: {fileID: 0} - quadMaterial: {fileID: 2100000, guid: 4c507f887c6274a44a603d96e0eabf2a, type: 2} + shaderPasses: ffffffff --- !u!114 &1786065615 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1057,6 +1095,9 @@ MonoBehaviour: materialsInsideMask: [] materialsOutsideMask: [] disableRenderingOnOverride: 1 + physicsPositionInheritanceFactor: {x: 1, y: 1} + physicsRotationInheritanceFactor: 1 + physicsMovementRelativeTo: {fileID: 0} updateTiming: 1 unscaledTime: 0 _animationName: run @@ -1073,6 +1114,7 @@ MeshRenderer: m_CastShadows: 1 m_ReceiveShadows: 1 m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 m_MotionVectors: 1 m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 @@ -1121,6 +1163,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 2.38, y: 0, z: 5.66} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 4 @@ -1164,6 +1207,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -4.7074776, y: 0.042612553, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 592567554} m_Father: {fileID: 0} @@ -1199,6 +1243,7 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0.3, y: 0.3, z: 0.3} + m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1089682727} m_Father: {fileID: 592567554} @@ -1233,6 +1278,7 @@ MonoBehaviour: additiveMaterial: {fileID: 2100000, guid: 2e8245019faeb8c43b75f9ca3ac8ee34, type: 2} multiplyMaterial: {fileID: 2100000, guid: e74a1f8978a7da348a721508d0d58834, type: 2} screenMaterial: {fileID: 2100000, guid: bab24c479f34eec45be6ea8595891569, type: 2} + m_SkeletonColor: {r: 1, g: 1, b: 1, a: 1} initialSkinName: default initialFlipX: 0 initialFlipY: 0 @@ -1240,6 +1286,14 @@ MonoBehaviour: startingLoop: 1 timeScale: 1 freeze: 0 + layoutScaleMode: 0 + referenceSize: {x: 2145.5999, y: 1302.059} + referencePivot: {x: 0.63858336, y: 0.010301443} + referencePivotOffset: {x: 1370.1444, y: 13.413086} + referenceScale: 1 + rectTransformSize: {x: 2145.5999, y: 1302.059} + rectTransformPivot: {x: 0, y: 0} + editReferenceRect: 0 updateWhenInvisible: 3 allowMultipleCanvasRenderers: 0 canvasRenderers: [] @@ -1247,16 +1301,20 @@ MonoBehaviour: enableSeparatorSlots: 0 separatorParts: [] updateSeparatorPartLocation: 1 + updateSeparatorPartScale: 0 disableMeshAssignmentOnOverride: 1 + physicsPositionInheritanceFactor: {x: 1, y: 1} + physicsRotationInheritanceFactor: 1 + physicsMovementRelativeTo: {fileID: 0} meshGenerator: settings: useClipping: 1 zSpacing: 0 - pmaVertexColors: 1 tintBlack: 0 - canvasGroupTintBlack: 0 - calculateTangents: 0 + canvasGroupCompatible: 0 + pmaVertexColors: 1 addNormals: 0 + calculateTangents: 0 immutableTriangles: 0 updateTiming: 1 unscaledTime: 0 @@ -1296,8 +1354,10 @@ MonoBehaviour: color: {r: 1, g: 1, b: 1, a: 1} maxRenderTextureSize: 1024 quad: {fileID: 0} + quadMaterial: {fileID: 2100000, guid: afeb0ae2ea2cda94796515bf8d1b3cb1, type: 2} renderTexture: {fileID: 0} targetCamera: {fileID: 0} + shaderPasses: ffffffff customRenderRect: {fileID: 1089682727} meshRendererMaterialForTexture: - texture: {fileID: 2800000, guid: 4ea2c33e839afb34c98f66e892b3b2d2, type: 3} diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/RenderQuadGraphicMaterial.mat b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/RenderQuadGraphicMaterial.mat new file mode 100644 index 000000000..0026de723 --- /dev/null +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/RenderQuadGraphicMaterial.mat @@ -0,0 +1,105 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: RenderQuadGraphicMaterial + m_Shader: {fileID: 4800000, guid: fa95b0fb6983c0f40a152e6f9aa82bfb, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: + - _ALPHAPREMULTIPLY_ON + - _USE8NEIGHBOURHOOD_ON + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _BumpScale: 1 + - _CanvasGroupCompatible: 0 + - _ColorMask: 15 + - _Cutoff: 0.5 + - _DarkColorAlphaAdditive: 0 + - _DetailNormalMapScale: 1 + - _DstBlend: 10 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 3 + - _OcclusionStrength: 1 + - _OutlineMipLevel: 0 + - _OutlineOpaqueAlpha: 1 + - _OutlineReferenceTexWidth: 1024 + - _OutlineSmoothness: 1 + - _OutlineWidth: 3 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilRef: 1 + - _StencilWriteMask: 255 + - _StraightAlphaInput: 0 + - _ThresholdEnd: 0.25 + - _UVSec: 0 + - _Use8Neighbourhood: 1 + - _UseUIAlphaClip: 0 + - _ZWrite: 0 + m_Colors: + - _Black: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _OutlineColor: {r: 1, g: 1, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/RenderQuadGraphicMaterial.mat.meta b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/RenderQuadGraphicMaterial.mat.meta new file mode 100644 index 000000000..ad6afa4b1 --- /dev/null +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/RenderQuadGraphicMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: afeb0ae2ea2cda94796515bf8d1b3cb1 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonGraphicRenderTexture.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonGraphicRenderTexture.cs index 05e5fc10b..5a0661be9 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonGraphicRenderTexture.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonGraphicRenderTexture.cs @@ -88,6 +88,9 @@ namespace Spine.Unity.Examples { quadMesh.MarkDynamic(); quadMesh.name = "RenderTexture Quad"; quadMesh.hideFlags = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor; + + if (quadMaterial == null) + quadMaterial = new Material(Shader.Find("Spine/SkeletonGraphic")); } void Reset () { @@ -101,6 +104,14 @@ namespace Spine.Unity.Examples { } } } + +#if UNITY_EDITOR + string[] assets = UnityEditor.AssetDatabase.FindAssets("t:material RenderQuadGraphicMaterial"); + if (assets.Length > 0) { + string materialPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assets[0]); + quadMaterial = UnityEditor.AssetDatabase.LoadAssetAtPath(materialPath); + } +#endif } void OnEnable () { @@ -212,7 +223,7 @@ namespace Spine.Unity.Examples { } protected void SetupQuad () { - quadCanvasRenderer.SetMaterial(Canvas.GetDefaultCanvasMaterial(), this.renderTexture); + quadCanvasRenderer.SetMaterial(quadMaterial, this.renderTexture); quadMaskableGraphic.color = color; quadCanvasRenderer.SetColor(color); diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonRenderTexture.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonRenderTexture.cs index 41417a2c3..5a0de0820 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonRenderTexture.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonRenderTexture.cs @@ -52,7 +52,6 @@ namespace Spine.Unity.Examples { [RequireComponent(typeof(SkeletonRenderer))] public class SkeletonRenderTexture : SkeletonRenderTextureBase { #if HAS_GET_SHARED_MATERIALS - public Material quadMaterial; protected SkeletonRenderer skeletonRenderer; protected MeshRenderer meshRenderer; protected MeshFilter meshFilter; diff --git a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonRenderTextureBase.cs b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonRenderTextureBase.cs index 99784806a..4cbfdd603 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonRenderTextureBase.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/Sample Components/SkeletonRenderTexture/SkeletonRenderTextureBase.cs @@ -42,6 +42,7 @@ namespace Spine.Unity.Examples { public Color color = Color.white; public int maxRenderTextureSize = 1024; public GameObject quad; + public Material quadMaterial; protected Mesh quadMesh; public RenderTexture renderTexture; public Camera targetCamera; diff --git a/spine-unity/Assets/Spine Examples/package.json b/spine-unity/Assets/Spine Examples/package.json index a183dd8f5..b6008ba45 100644 --- a/spine-unity/Assets/Spine Examples/package.json +++ b/spine-unity/Assets/Spine Examples/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.spine-unity-examples", "displayName": "spine-unity Runtime Examples", "description": "This plugin provides example scenes and scripts for the spine-unity runtime.", - "version": "4.2.29", + "version": "4.2.30", "unity": "2018.3", "author": { "name": "Esoteric Software",