mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[unity] Added Spine/SkeletonGraphic Grayscale shader.
This commit is contained in:
parent
85a972922a
commit
c191282f54
@ -30,6 +30,7 @@
|
||||
|
||||
* **Additions**
|
||||
* `OnPostProcessVertices` callback parameter `MeshGeneratorBuffers` now provides access to `uv2Buffer` and `uv3Buffer` properties of `MeshGenerator`, automatically allocating buffers upon access if `tintBlack` is disabled. This allows for passing own vertex data to a shader on second and third uv channels.
|
||||
* Added `Spine/SkeletonGraphic Grayscale` shader to provide a basic grayscale shader for SkeletonGraphic as well. SkeletonGraphic Material `SkeletonGraphicDefaultGrayscale` uses this shader and can be assigned at `SkeletonGraphic` components as usual.
|
||||
|
||||
* **Breaking changes**
|
||||
|
||||
|
||||
@ -2,20 +2,25 @@
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: SkeletonGraphicDefaultGrayscale
|
||||
m_Shader: {fileID: 4800000, guid: fa95b0fb6983c0f40a152e6f9aa82bfb, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_Shader: {fileID: 4800000, guid: 81eed00979b4e554cb3022dc0b83b517, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- _USE8NEIGHBOURHOOD_ON
|
||||
m_LightmapFlags: 5
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
@ -59,6 +64,7 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- PixelSnap: 0
|
||||
- _BumpScale: 1
|
||||
@ -69,10 +75,12 @@ Material:
|
||||
- _DstBlend: 0
|
||||
- _EnableExternalAlpha: 0
|
||||
- _Glossiness: 0.5
|
||||
- _GrayPhase: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _OutlineMipLevel: 0
|
||||
- _OutlineOpaqueAlpha: 1
|
||||
- _OutlineReferenceTexWidth: 1024
|
||||
- _OutlineSmoothness: 1
|
||||
- _OutlineWidth: 3
|
||||
|
||||
@ -22,7 +22,9 @@ struct VertexOutput {
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
#ifndef ENABLE_GRAYSCALE
|
||||
fixed4 _Color;
|
||||
#endif
|
||||
fixed4 _TextureSampleAdd;
|
||||
float4 _ClipRect;
|
||||
|
||||
@ -30,6 +32,9 @@ float4 _ClipRect;
|
||||
float4 _FillColor;
|
||||
float _FillPhase;
|
||||
#endif
|
||||
#ifdef ENABLE_GRAYSCALE
|
||||
float _GrayPhase;
|
||||
#endif
|
||||
|
||||
VertexOutput vert (VertexInput IN) {
|
||||
VertexOutput OUT;
|
||||
@ -57,7 +62,11 @@ VertexOutput vert (VertexInput IN) {
|
||||
// Saturated version used to prevent numerical issues of certain low-alpha values.
|
||||
float4 vertexColor = PMAGammaToTargetSpaceSaturated(half4(TargetToGammaSpace(IN.color.rgb), IN.color.a));
|
||||
#endif
|
||||
OUT.color = vertexColor * float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
|
||||
OUT.color = vertexColor;
|
||||
#ifndef ENABLE_GRAYSCALE
|
||||
OUT.color *= float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
|
||||
#endif
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
@ -81,6 +90,9 @@ fixed4 frag (VertexOutput IN) : SV_Target
|
||||
#ifdef ENABLE_FILL
|
||||
color.rgb = lerp(color.rgb, (_FillColor.rgb * color.a), _FillPhase); // make sure to PMA _FillColor.
|
||||
#endif
|
||||
#ifdef ENABLE_GRAYSCALE
|
||||
color.rgb = lerp(color.rgb, dot(color.rgb, float3(0.3, 0.59, 0.11)), _GrayPhase);
|
||||
#endif
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
@ -19,60 +19,60 @@ Shader "Spine/SkeletonGraphic Fill"
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip("Use Alpha Clip", Float) = 0
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineOpaqueAlpha("Opaque Alpha", Range(0,1)) = 1.0
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineOpaqueAlpha("Opaque Alpha", Range(0,1)) = 1.0
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"IgnoreProjector" = "True"
|
||||
"RenderType" = "Transparent"
|
||||
"PreviewType" = "Plane"
|
||||
"CanUseSpriteAtlas" = "True"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest[unity_GUIZTestMode]
|
||||
Fog { Mode Off }
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Normal"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||
#pragma shader_feature _ _CANVAS_GROUP_COMPATIBLE
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#define ENABLE_FILL
|
||||
#include "CGIncludes/Spine-SkeletonGraphic-NormalPass.cginc"
|
||||
ENDCG
|
||||
}
|
||||
"Queue" = "Transparent"
|
||||
"IgnoreProjector" = "True"
|
||||
"RenderType" = "Transparent"
|
||||
"PreviewType" = "Plane"
|
||||
"CanUseSpriteAtlas" = "True"
|
||||
}
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest[unity_GUIZTestMode]
|
||||
Fog { Mode Off }
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Normal"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||
#pragma shader_feature _ _CANVAS_GROUP_COMPATIBLE
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#define ENABLE_FILL
|
||||
#include "CGIncludes/Spine-SkeletonGraphic-NormalPass.cginc"
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
|
||||
@ -0,0 +1,76 @@
|
||||
Shader "Spine/SkeletonGraphic Grayscale"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_GrayPhase("Phase", Range(0, 1)) = 1
|
||||
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
[Toggle(_CANVAS_GROUP_COMPATIBLE)] _CanvasGroupCompatible("CanvasGroup Compatible", Int) = 1
|
||||
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8
|
||||
[HideInInspector] _Stencil("Stencil ID", Float) = 0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.StencilOp)] _StencilOp("Stencil Operation", Float) = 0
|
||||
[HideInInspector] _StencilWriteMask("Stencil Write Mask", Float) = 255
|
||||
[HideInInspector] _StencilReadMask("Stencil Read Mask", Float) = 255
|
||||
|
||||
[HideInInspector] _ColorMask("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip("Use Alpha Clip", Float) = 0
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineOpaqueAlpha("Opaque Alpha", Range(0,1)) = 1.0
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"IgnoreProjector" = "True"
|
||||
"RenderType" = "Transparent"
|
||||
"PreviewType" = "Plane"
|
||||
"CanUseSpriteAtlas" = "True"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest[unity_GUIZTestMode]
|
||||
Fog { Mode Off }
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Normal"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||
#pragma shader_feature _ _CANVAS_GROUP_COMPATIBLE
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#define ENABLE_GRAYSCALE
|
||||
#include "CGIncludes/Spine-SkeletonGraphic-NormalPass.cginc"
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81eed00979b4e554cb3022dc0b83b517
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
x
Reference in New Issue
Block a user