From 16b95b971b7ffbb1aae4b3a0e4a5fcdccf23bd0a Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 2 Dec 2020 20:16:37 +0100 Subject: [PATCH] [unity] Now all URP and LWRP shaders support SRP batching. Closes #1813. --- CHANGELOG.md | 1 + .../CGIncludes/Spine-Outline-Common.cginc | 42 +++++++++++++++++ .../Spine-Outline-Common.cginc.meta | 9 ++++ .../CGIncludes/Spine-Outline-Pass.cginc | 37 ++------------- .../Sprite/CGIncludes/ShaderShared.cginc | 14 ++++++ .../Sprite/CGIncludes/SpriteLighting.cginc | 5 ++ .../CGIncludes/Spine-DepthOnlyPass-LW.hlsl | 20 ++++---- .../Shaders/CGIncludes/Spine-Input-LW.hlsl | 46 ++++--------------- .../CGIncludes/Spine-Input-Outline-LW.hlsl | 26 +++++++++++ .../Spine-Input-Outline-LW.hlsl.meta | 9 ++++ .../CGIncludes/Spine-Input-Sprite-LW.hlsl | 33 +++++++++++++ .../Spine-Input-Sprite-LW.hlsl.meta | 9 ++++ .../CGIncludes/Spine-Outline-Pass-LW.hlsl | 43 +++++++++++++++++ .../Spine-Outline-Pass-LW.hlsl.meta | 9 ++++ .../Spine-Skeleton-ForwardPass-LW.hlsl | 7 +-- .../Spine-SkeletonLit-ForwardPass-LW.hlsl | 6 ++- ...Spine-SkeletonLit-ShadowCasterPass-LW.hlsl | 41 +++++++++++++++-- .../CGIncludes/Spine-Sprite-Common-LW.hlsl | 39 ++++++++++++++++ .../Spine-Sprite-Common-LW.hlsl.meta | 9 ++++ .../Spine-Sprite-DepthOnlyPass-LW.hlsl | 42 +++++++++++++++++ .../Spine-Sprite-DepthOnlyPass-LW.hlsl.meta | 9 ++++ .../Spine-Sprite-ForwardPass-LW.hlsl | 2 +- .../Spine-Sprite-ShadowCasterPass-LW.hlsl | 40 ++++++++++++++-- .../Spine-Outline-Common.cginc | 2 + .../Spine-Outline-Common.cginc.meta | 9 ++++ ...r => Spine-Skeleton-OutlineOnly-LW.shader} | 24 +++++++++- ...Spine-Skeleton-OutlineOnly-LW.shader.meta} | 0 .../Shaders/Spine-Skeleton-LW.shader | 18 ++------ .../Shaders/Spine-SkeletonLit-LW.shader | 14 ++---- .../Shaders/Spine-Sprite-LW.shader | 18 ++------ .../Shaders/2D/Spine-Sprite-URP-2D.shader | 2 + .../Spine-Common-ShadowCasterPass-URP.hlsl | 4 +- .../Include/Spine-DepthOnlyPass-URP.hlsl | 18 ++++---- .../Include/Spine-Input-Outline-URP.hlsl | 26 +++++++++++ .../Include/Spine-Input-Outline-URP.hlsl.meta | 9 ++++ .../Include/Spine-Input-Sprite-URP.hlsl | 33 +++++++++++++ .../Include/Spine-Input-Sprite-URP.hlsl.meta | 9 ++++ .../Shaders/Include/Spine-Input-URP.hlsl | 40 ++-------------- .../Include/Spine-Outline-Pass-URP.hlsl | 43 +++++++++++++++++ .../Include/Spine-Outline-Pass-URP.hlsl.meta | 9 ++++ .../Spine-Skeleton-ForwardPass-URP.hlsl | 7 +-- .../Spine-SkeletonLit-ForwardPass-URP.hlsl | 6 ++- ...pine-SkeletonLit-ShadowCasterPass-URP.hlsl | 39 +++++++++++++++- .../Include/Spine-Sprite-Common-URP.hlsl | 39 ++++++++++++++++ .../Include/Spine-Sprite-Common-URP.hlsl.meta | 9 ++++ .../Spine-Sprite-DepthOnlyPass-URP.hlsl | 42 +++++++++++++++++ .../Spine-Sprite-DepthOnlyPass-URP.hlsl.meta | 9 ++++ .../Include/Spine-Sprite-ForwardPass-URP.hlsl | 2 +- .../Spine-Sprite-ShadowCasterPass-URP.hlsl | 38 ++++++++++++++- .../Spine-Outline-Common.cginc | 2 + .../Spine-Outline-Common.cginc.meta | 9 ++++ .../Spine-Skeleton-OutlineOnly-URP.shader | 24 +++++++++- .../Shaders/Spine-Skeleton-URP.shader | 14 ++---- .../Shaders/Spine-SkeletonLit-URP.shader | 16 ++----- .../Shaders/Spine-Sprite-URP.shader | 18 ++------ 55 files changed, 826 insertions(+), 224 deletions(-) create mode 100644 spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc create mode 100644 spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc.meta create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Outline-LW.hlsl create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Outline-LW.hlsl.meta create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Sprite-LW.hlsl create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Sprite-LW.hlsl.meta create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Outline-Pass-LW.hlsl create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Outline-Pass-LW.hlsl.meta create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-Common-LW.hlsl create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-Common-LW.hlsl.meta create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-DepthOnlyPass-LW.hlsl create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-DepthOnlyPass-LW.hlsl.meta create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/SpineCoreShaders/Spine-Outline-Common.cginc create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/SpineCoreShaders/Spine-Outline-Common.cginc.meta rename spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Outline/{Spine-Skeleton-OutlineOnly-LWRP.shader => Spine-Skeleton-OutlineOnly-LW.shader} (70%) rename spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Outline/{Spine-Skeleton-OutlineOnly-LWRP.shader.meta => Spine-Skeleton-OutlineOnly-LW.shader.meta} (100%) create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Outline-URP.hlsl create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Outline-URP.hlsl.meta create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Sprite-URP.hlsl create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Sprite-URP.hlsl.meta create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Outline-Pass-URP.hlsl create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Outline-Pass-URP.hlsl.meta create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-Common-URP.hlsl create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-Common-URP.hlsl.meta create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthOnlyPass-URP.hlsl create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthOnlyPass-URP.hlsl.meta create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/Spine-Outline-Common.cginc create mode 100644 spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/Spine-Outline-Common.cginc.meta diff --git a/CHANGELOG.md b/CHANGELOG.md index 7605c991b..d56a2af94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -248,6 +248,7 @@ * Added Inspector context menu functions `SkeletonRenderer - Add all BoundingBoxFollower GameObjects` and `SkeletonGraphic - Add all BoundingBoxFollowerGraphic GameObjects` that automatically generate bounding box follower GameObjects for every `BoundingBoxAttachment` for all skins of a skeleton. * `GetRemappedClone()` now provides an additional parameter `pivotShiftsMeshUVCoords` for `MeshAttachment` to prevent uv shifts at a non-central Sprite pivot. This parameter defaults to `true` to maintain previous behaviour. * `SkeletonRenderer` components now provide an additional update mode `Only Event Timelines` at the `Update When Invisible` property. This mode saves additional timeline updates compared to update mode `Everything Except Mesh`. + * Now all URP (Universal Render Pipeline) and LWRP (Lightweight Render Pipeline) shaders support SRP (Scriptable Render Pipeline) batching. See [Unity SRPBatcher documentation pages](https://docs.unity3d.com/Manual/SRPBatcher.html) for additional information. * **Changes of default values** * `SkeletonMecanim`'s `Layer Mix Mode` now defaults to `MixMode.MixNext` instead of `MixMode.MixAlways`. diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc new file mode 100644 index 000000000..ca5b10517 --- /dev/null +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc @@ -0,0 +1,42 @@ +#ifndef SPINE_OUTLINE_COMMON_INCLUDED +#define SPINE_OUTLINE_COMMON_INCLUDED + +float4 computeOutlinePixel(sampler2D mainTexture, float2 mainTextureTexelSize, + float2 uv, float vertexColorAlpha, + float OutlineWidth, float OutlineReferenceTexWidth, float OutlineMipLevel, + float OutlineSmoothness, float ThresholdEnd, float4 OutlineColor) { + + float4 texColor = fixed4(0, 0, 0, 0); + + float outlineWidthCompensated = OutlineWidth / (OutlineReferenceTexWidth * mainTextureTexelSize.x); + float xOffset = mainTextureTexelSize.x * outlineWidthCompensated; + float yOffset = mainTextureTexelSize.y * outlineWidthCompensated; + float xOffsetDiagonal = mainTextureTexelSize.x * outlineWidthCompensated * 0.7; + float yOffsetDiagonal = mainTextureTexelSize.y * outlineWidthCompensated * 0.7; + + float pixelCenter = tex2D(mainTexture, uv).a; + + float4 uvCenterWithLod = float4(uv, 0, OutlineMipLevel); + float pixelTop = tex2Dlod(mainTexture, uvCenterWithLod + float4(0, yOffset, 0, 0)).a; + float pixelBottom = tex2Dlod(mainTexture, uvCenterWithLod + float4(0, -yOffset, 0, 0)).a; + float pixelLeft = tex2Dlod(mainTexture, uvCenterWithLod + float4(-xOffset, 0, 0, 0)).a; + float pixelRight = tex2Dlod(mainTexture, uvCenterWithLod + float4(xOffset, 0, 0, 0)).a; +#if _USE8NEIGHBOURHOOD_ON + float numSamples = 8; + float pixelTopLeft = tex2Dlod(mainTexture, uvCenterWithLod + float4(-xOffsetDiagonal, yOffsetDiagonal, 0, 0)).a; + float pixelTopRight = tex2Dlod(mainTexture, uvCenterWithLod + float4(xOffsetDiagonal, yOffsetDiagonal, 0, 0)).a; + float pixelBottomLeft = tex2Dlod(mainTexture, uvCenterWithLod + float4(-xOffsetDiagonal, -yOffsetDiagonal, 0, 0)).a; + float pixelBottomRight = tex2Dlod(mainTexture, uvCenterWithLod + float4(xOffsetDiagonal, -yOffsetDiagonal, 0, 0)).a; + float average = (pixelTop + pixelBottom + pixelLeft + pixelRight + + pixelTopLeft + pixelTopRight + pixelBottomLeft + pixelBottomRight) + * vertexColorAlpha / numSamples; +#else // 4 neighbourhood + float numSamples = 1; + float average = (pixelTop + pixelBottom + pixelLeft + pixelRight) * vertexColorAlpha / numSamples; +#endif + float thresholdStart = ThresholdEnd * (1.0 - OutlineSmoothness); + float outlineAlpha = saturate((average - thresholdStart) / (ThresholdEnd - thresholdStart)) - pixelCenter; + return lerp(texColor, OutlineColor, outlineAlpha); +} + +#endif diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc.meta b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc.meta new file mode 100644 index 000000000..add934092 --- /dev/null +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a8d610b87be4e82409e18a63a930d335 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/CGIncludes/Spine-Outline-Pass.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/CGIncludes/Spine-Outline-Pass.cginc index 7ed2a2861..3ffdbf42d 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/CGIncludes/Spine-Outline-Pass.cginc +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Outline/CGIncludes/Spine-Outline-Pass.cginc @@ -7,6 +7,8 @@ #include "UnityUI.cginc" #endif +#include "../../CGIncludes/Spine-Outline-Common.cginc" + sampler2D _MainTex; float _OutlineWidth; @@ -76,38 +78,9 @@ VertexOutput vertOutline(VertexInput v) { float4 fragOutline(VertexOutput i) : SV_Target { - float4 texColor = fixed4(0,0,0,0); - - float outlineWidthCompensated = _OutlineWidth / (_OutlineReferenceTexWidth * _MainTex_TexelSize.x); - float xOffset = _MainTex_TexelSize.x * outlineWidthCompensated; - float yOffset = _MainTex_TexelSize.y * outlineWidthCompensated; - float xOffsetDiagonal = _MainTex_TexelSize.x * outlineWidthCompensated * 0.7; - float yOffsetDiagonal = _MainTex_TexelSize.y * outlineWidthCompensated * 0.7; - - float pixelCenter = tex2D(_MainTex, i.uv).a; - - float4 uvCenterWithLod = float4(i.uv, 0, _OutlineMipLevel); - float pixelTop = tex2Dlod(_MainTex, uvCenterWithLod + float4(0, yOffset, 0, 0)).a; - float pixelBottom = tex2Dlod(_MainTex, uvCenterWithLod + float4(0, -yOffset, 0, 0)).a; - float pixelLeft = tex2Dlod(_MainTex, uvCenterWithLod + float4(-xOffset, 0, 0, 0)).a; - float pixelRight = tex2Dlod(_MainTex, uvCenterWithLod + float4(xOffset, 0, 0, 0)).a; -#if _USE8NEIGHBOURHOOD_ON - float numSamples = 8; - float pixelTopLeft = tex2Dlod(_MainTex, uvCenterWithLod + float4(-xOffsetDiagonal, yOffsetDiagonal, 0, 0)).a; - float pixelTopRight = tex2Dlod(_MainTex, uvCenterWithLod + float4(xOffsetDiagonal, yOffsetDiagonal, 0, 0)).a; - float pixelBottomLeft = tex2Dlod(_MainTex, uvCenterWithLod + float4(-xOffsetDiagonal, -yOffsetDiagonal, 0, 0)).a; - float pixelBottomRight = tex2Dlod(_MainTex, uvCenterWithLod + float4(xOffsetDiagonal, -yOffsetDiagonal, 0, 0)).a; - float average = (pixelTop + pixelBottom + pixelLeft + pixelRight + - pixelTopLeft + pixelTopRight + pixelBottomLeft + pixelBottomRight) - * i.vertexColorAlpha / numSamples; -#else // 4 neighbourhood - float numSamples = 1; - float average = (pixelTop + pixelBottom + pixelLeft + pixelRight) * i.vertexColorAlpha / numSamples; -#endif - - float thresholdStart = _ThresholdEnd * (1.0 - _OutlineSmoothness); - float outlineAlpha = saturate((average - thresholdStart) / (_ThresholdEnd - thresholdStart)) - pixelCenter; - texColor.rgba = lerp(texColor, _OutlineColor, outlineAlpha); + float4 texColor = computeOutlinePixel(_MainTex, _MainTex_TexelSize.xy, i.uv, i.vertexColorAlpha, + _OutlineWidth, _OutlineReferenceTexWidth, _OutlineMipLevel, + _OutlineSmoothness, _ThresholdEnd, _OutlineColor); #ifdef SKELETON_GRAPHIC texColor *= UnityGet2DClipping(i.worldPosition.xy, _ClipRect); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc index 460d1629e..f7d6ffc65 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/ShaderShared.cginc @@ -74,7 +74,10 @@ inline half3 calculateWorldNormal(float3 normal) #if defined(_NORMALMAP) uniform sampler2D _BumpMap; + +#if !defined(USE_LWRP) && !defined(USE_URP) uniform half _BumpScale; +#endif half3 UnpackScaleNormal(half4 packednormal, half bumpScale) { @@ -225,7 +228,9 @@ inline fixed4 calculatePixel(fixed4 texureColor) : SV_Target #if defined(_ALPHA_CLIP) +#if !defined(USE_LWRP) && !defined(USE_URP) uniform fixed _Cutoff; +#endif #define ALPHA_CLIP(pixel, color) clip((pixel.a * color.a) - _Cutoff); @@ -239,7 +244,9 @@ uniform fixed _Cutoff; // Color functions // +#if !defined(USE_LWRP) && !defined(USE_URP) uniform fixed4 _Color; +#endif inline fixed4 calculateVertexColor(fixed4 color) { @@ -248,10 +255,12 @@ inline fixed4 calculateVertexColor(fixed4 color) #if defined(_COLOR_ADJUST) +#if !defined(USE_LWRP) && !defined(USE_URP) uniform float _Hue; uniform float _Saturation; uniform float _Brightness; uniform fixed4 _OverlayColor; +#endif float3 rgb2hsv(float3 c) { @@ -354,7 +363,9 @@ uniform sampler2D _MainTex; #if _TEXTURE_BLEND uniform sampler2D _BlendTex; +#if !defined(USE_LWRP) && !defined(USE_URP) uniform float _BlendAmount; +#endif inline fixed4 calculateBlendedTexturePixel(float2 texcoord) { @@ -379,11 +390,14 @@ inline fixed4 calculateTexturePixel(float2 texcoord) return pixel; } +#if !defined(USE_LWRP) && !defined(USE_URP) uniform fixed4 _MainTex_ST; +#endif inline float2 calculateTextureCoord(float4 texcoord) { return TRANSFORM_TEX(texcoord, _MainTex); } + #endif // SHADER_SHARED_INCLUDED diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteLighting.cginc b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteLighting.cginc index 3d8824935..36005cd50 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteLighting.cginc +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Shaders/Sprite/CGIncludes/SpriteLighting.cginc @@ -33,7 +33,9 @@ struct VertexInput // Normal functions // +#if !defined(USE_LWRP) && !defined(USE_URP) uniform float4 _FixedNormal = float4(0, 0, 1, 1); +#endif inline float3 getFixedNormal() { @@ -189,8 +191,11 @@ inline fixed3 applyRimLighting(fixed3 posWorld, fixed3 normalWorld, fixed4 pixel #ifdef _EMISSION uniform sampler2D _EmissionMap; + +#if !defined(USE_LWRP) && !defined(USE_URP) uniform fixed4 _EmissionColor; uniform float _EmissionPower; +#endif #define APPLY_EMISSION(diffuse, uv) diffuse += tex2D(_EmissionMap, uv).rgb * _EmissionColor.rgb * _EmissionPower; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-DepthOnlyPass-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-DepthOnlyPass-LW.hlsl index b261da9a4..c82c4db6e 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-DepthOnlyPass-LW.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-DepthOnlyPass-LW.hlsl @@ -1,41 +1,41 @@ #ifndef SPRITES_DEPTH_ONLY_PASS_LW_INCLUDED #define SPRITES_DEPTH_ONLY_PASS_LW_INCLUDED +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" #include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl" -#include "SpineCoreShaders/ShaderShared.cginc" -struct AttributesSprite +struct AttributesSpine { float4 positionOS : POSITION; + float3 normalOS : NORMAL; float4 vertexColor : COLOR; float2 texcoord : TEXCOORD0; UNITY_VERTEX_INPUT_INSTANCE_ID }; -struct VaryingsSprite +struct VaryingsSpine { float4 positionCS : SV_POSITION; float4 texcoordAndAlpha: TEXCOORD0; - UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; -VaryingsSprite DepthOnlyVertexSprite(AttributesSprite input) +VaryingsSpine DepthOnlyVertex(AttributesSpine input) { - VaryingsSprite output = (VaryingsSprite)0; + VaryingsSpine output = (VaryingsSpine)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); output.texcoordAndAlpha.xyz = float3(TRANSFORM_TEX(input.texcoord, _MainTex).xy, 0); - output.texcoordAndAlpha.a = input.vertexColor.a * _Color.a; + output.texcoordAndAlpha.a = input.vertexColor.a; output.positionCS = TransformObjectToHClip(input.positionOS.xyz); return output; } -half4 DepthOnlyFragmentSprite(VaryingsSprite input) : SV_TARGET +half4 DepthOnlyFragment(VaryingsSpine input) : SV_TARGET { - fixed4 texureColor = calculateTexturePixel(input.texcoordAndAlpha.xy); - clip(texureColor.a * input.texcoordAndAlpha.a - _Cutoff); + fixed4 texureColor = tex2D(_MainTex, input.texcoordAndAlpha.xy); + clip(texureColor.a* input.texcoordAndAlpha.a - _Cutoff); return 0; } diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-LW.hlsl index 6bf9a6d8c..7f3859154 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-LW.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-LW.hlsl @@ -1,48 +1,18 @@ -#ifndef LIGHTWEIGHT_LIT_INPUT_INCLUDED -#define LIGHTWEIGHT_LIT_INPUT_INCLUDED +#ifndef LW_LIT_INPUT_INCLUDED +#define LW_LIT_INPUT_INCLUDED + +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" //////////////////////////////////////// // Defines // #undef LIGHTMAP_ON -#if defined(_SPECULAR) || defined(_SPECULAR_GLOSSMAP) -#define SPECULAR -#endif - -//Have to process lighting per pixel if using normal maps or a diffuse ramp or rim lighting or specular -#if defined(_NORMALMAP) || defined(_DIFFUSE_RAMP) || defined(_RIM_LIGHTING) || defined(SPECULAR) -#define PER_PIXEL_LIGHTING -#endif - -#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl" -#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" -#include "SpineCoreShaders/ShaderShared.cginc" - -#if defined(SPECULAR) - CBUFFER_START(UnityPerMaterial) -half _Metallic; -half _Glossiness; -half _GlossMapScale; +float4 _MainTex_ST; +half _Cutoff; CBUFFER_END -sampler2D _MetallicGlossMap; +sampler2D _MainTex; -inline half2 getMetallicGloss(float2 uv) -{ - half2 mg; - -#ifdef _SPECULAR_GLOSSMAP - mg = tex2D(_MetallicGlossMap, uv).ra; - mg.g *= _GlossMapScale; -#else - mg.r = _Metallic; - mg.g = _Glossiness; -#endif - - return mg; -} -#endif - -#endif // LIGHTWEIGHT_INPUT_SURFACE_PBR_INCLUDED +#endif // LW_LIT_INPUT_INCLUDED diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Outline-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Outline-LW.hlsl new file mode 100644 index 000000000..b9ab7e364 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Outline-LW.hlsl @@ -0,0 +1,26 @@ +#ifndef LWRP_INPUT_OUTLINE_INCLUDED +#define LWRP_INPUT_OUTLINE_INCLUDED + +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + +//////////////////////////////////////// +// Defines +// +#undef LIGHTMAP_ON + +CBUFFER_START(UnityPerMaterial) +float4 _MainTex_ST; +half _Cutoff; + +float _OutlineWidth; +float4 _OutlineColor; +float4 _MainTex_TexelSize; +float _ThresholdEnd; +float _OutlineSmoothness; +float _OutlineMipLevel; +int _OutlineReferenceTexWidth; +CBUFFER_END + +sampler2D _MainTex; + +#endif // URP_INPUT_OUTLINE_INCLUDED diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Outline-LW.hlsl.meta b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Outline-LW.hlsl.meta new file mode 100644 index 000000000..50c7cbb99 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Outline-LW.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9cbef8e6101ae9e478dbb082dc9bb2f0 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Sprite-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Sprite-LW.hlsl new file mode 100644 index 000000000..d73db894d --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Sprite-LW.hlsl @@ -0,0 +1,33 @@ +#ifndef LIGHTWEIGHT_INPUT_SPRITE_INCLUDED +#define LIGHTWEIGHT_INPUT_SPRITE_INCLUDED + +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + +CBUFFER_START(UnityPerMaterial) + +float4 _MainTex_ST; +half4 _Color; +half _Cutoff; +half _ShadowAlphaCutoff; + +half _Metallic; +half _Glossiness; +half _GlossMapScale; + +half _BumpScale; + +float _BlendAmount; + +float _Hue; +float _Saturation; +float _Brightness; +half4 _OverlayColor; + +half4 _EmissionColor; +float _EmissionPower; + +float4 _FixedNormal; + +CBUFFER_END + +#endif // LIGHTWEIGHT_INPUT_SPRITE_INCLUDED diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Sprite-LW.hlsl.meta b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Sprite-LW.hlsl.meta new file mode 100644 index 000000000..ba6ac1124 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Input-Sprite-LW.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f1cab442214f2534a88ae31916cada93 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Outline-Pass-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Outline-Pass-LW.hlsl new file mode 100644 index 000000000..42cf4140f --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Outline-Pass-LW.hlsl @@ -0,0 +1,43 @@ +#ifndef SPINE_OUTLINE_PASS_LW_INCLUDED +#define SPINE_OUTLINE_PASS_LW_INCLUDED + +#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" + +#include "SpineCoreShaders/Spine-Outline-Common.cginc" + +struct VertexInput { + float4 positionOS : POSITION; + float2 uv : TEXCOORD0; + float4 vertexColor : COLOR; + UNITY_VERTEX_INPUT_INSTANCE_ID +}; + +struct VertexOutput { + float4 pos : SV_POSITION; + float2 uv : TEXCOORD0; + float vertexColorAlpha : COLOR; + UNITY_VERTEX_OUTPUT_STEREO +}; + +VertexOutput vertOutline(VertexInput v) { + VertexOutput o; + + UNITY_SETUP_INSTANCE_ID(v); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); + + o.pos = TransformObjectToHClip(v.positionOS.xyz); + o.uv = v.uv; + o.vertexColorAlpha = v.vertexColor.a; + return o; +} + +float4 fragOutline(VertexOutput i) : SV_Target{ + + float4 texColor = computeOutlinePixel(_MainTex, _MainTex_TexelSize.xy, i.uv, i.vertexColorAlpha, + _OutlineWidth, _OutlineReferenceTexWidth, _OutlineMipLevel, + _OutlineSmoothness, _ThresholdEnd, _OutlineColor); + return texColor; +} + +#endif diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Outline-Pass-LW.hlsl.meta b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Outline-Pass-LW.hlsl.meta new file mode 100644 index 000000000..3e68459f9 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Outline-Pass-LW.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: dc29d6aca678ea942977c7b8f55ed9f1 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Skeleton-ForwardPass-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Skeleton-ForwardPass-LW.hlsl index d9067d8cd..1ab64c941 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Skeleton-ForwardPass-LW.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Skeleton-ForwardPass-LW.hlsl @@ -1,11 +1,14 @@ #ifndef SKELETON_FORWARD_PASS_LW_INCLUDED #define SKELETON_FORWARD_PASS_LW_INCLUDED +#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" + struct appdata { float3 pos : POSITION; half4 color : COLOR; float2 uv0 : TEXCOORD0; - + UNITY_VERTEX_INPUT_INSTANCE_ID }; @@ -28,8 +31,6 @@ VertexOutput vert(appdata v) { return o; } -sampler2D _MainTex; - half4 frag(VertexOutput i) : SV_Target{ float4 texColor = tex2D(_MainTex, i.uv0); diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ForwardPass-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ForwardPass-LW.hlsl index b6b54affb..c22d45e13 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ForwardPass-LW.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ForwardPass-LW.hlsl @@ -1,6 +1,10 @@ #ifndef SKELETONLIT_FORWARD_PASS_LW_INCLUDED #define SKELETONLIT_FORWARD_PASS_LW_INCLUDED +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" +#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Lighting.hlsl" + struct appdata { float3 pos : POSITION; float3 normal : NORMAL; @@ -66,8 +70,6 @@ VertexOutput vert(appdata v) { return o; } -sampler2D _MainTex; - half4 frag(VertexOutput i) : SV_Target{ half4 tex = tex2D(_MainTex, i.uv0); half4 col; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ShadowCasterPass-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ShadowCasterPass-LW.hlsl index 1158bc296..97d09a81d 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ShadowCasterPass-LW.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-SkeletonLit-ShadowCasterPass-LW.hlsl @@ -1,7 +1,42 @@ #ifndef SKELETONLIT_SHADOW_CASTER_PASS_LW_INCLUDED #define SKELETONLIT_SHADOW_CASTER_PASS_LW_INCLUDED -#include "Spine-Common-ShadowCasterPass-LW.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" +#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Shadows.hlsl" + +float3 _LightDirection; + +struct AttributesSpine +{ + float4 positionOS : POSITION; + float3 normalOS : NORMAL; + float4 vertexColor : COLOR; + float2 texcoord : TEXCOORD0; + UNITY_VERTEX_INPUT_INSTANCE_ID +}; + +struct VaryingsSpine +{ + float4 positionCS : SV_POSITION; + float4 texcoordAndAlpha: TEXCOORD0; +}; + +float4 GetShadowPositionHClip(AttributesSpine input) +{ + float3 positionWS = TransformObjectToWorld(input.positionOS.xyz); + float3 normalWS = TransformObjectToWorldNormal(input.normalOS); + + float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection)); + +#if UNITY_REVERSED_Z + positionCS.z = min(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE); +#else + positionCS.z = max(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE); +#endif + + return positionCS; +} VaryingsSpine ShadowPassVertexSkeletonLit(AttributesSpine input) { @@ -16,8 +51,8 @@ VaryingsSpine ShadowPassVertexSkeletonLit(AttributesSpine input) half4 ShadowPassFragmentSkeletonLit(VaryingsSpine input) : SV_TARGET { - fixed4 texureColor = calculateTexturePixel(input.texcoordAndAlpha.xy); - clip(texureColor.a * input.texcoordAndAlpha.a - _Cutoff); + fixed4 texureColor = tex2D(_MainTex, input.texcoordAndAlpha.xy); + clip(texureColor.a* input.texcoordAndAlpha.a - _Cutoff); return 0; } diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-Common-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-Common-LW.hlsl new file mode 100644 index 000000000..0141bdac1 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-Common-LW.hlsl @@ -0,0 +1,39 @@ +#ifndef LW_SPRITE_COMMON_INCLUDED +#define LW_SPRITE_COMMON_INCLUDED + +#undef LIGHTMAP_ON + +#if defined(_SPECULAR) || defined(_SPECULAR_GLOSSMAP) +#define SPECULAR +#endif + +//Have to process lighting per pixel if using normal maps or a diffuse ramp or rim lighting or specular +#if defined(_NORMALMAP) || defined(_DIFFUSE_RAMP) || defined(_RIM_LIGHTING) || defined(SPECULAR) +#define PER_PIXEL_LIGHTING +#endif + +#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" +#include "SpineCoreShaders/ShaderShared.cginc" + +#if defined(SPECULAR) + +sampler2D _MetallicGlossMap; + +inline half2 getMetallicGloss(float2 uv) +{ + half2 mg; + +#ifdef _SPECULAR_GLOSSMAP + mg = tex2D(_MetallicGlossMap, uv).ra; + mg.g *= _GlossMapScale; +#else + mg.r = _Metallic; + mg.g = _Glossiness; +#endif + + return mg; +} +#endif + +#endif // LW_SPRITE_COMMON_INCLUDED diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-Common-LW.hlsl.meta b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-Common-LW.hlsl.meta new file mode 100644 index 000000000..ce0a39651 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-Common-LW.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 678ff30f3610c7d488dffe8e3a9992ea +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-DepthOnlyPass-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-DepthOnlyPass-LW.hlsl new file mode 100644 index 000000000..0871e79ae --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-DepthOnlyPass-LW.hlsl @@ -0,0 +1,42 @@ +#ifndef SPRITES_DEPTH_ONLY_PASS_LW_INCLUDED +#define SPRITES_DEPTH_ONLY_PASS_LW_INCLUDED + +#include "CGIncludes/Spine-Sprite-Common-LW.hlsl" +#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl" + +struct AttributesSprite +{ + float4 positionOS : POSITION; + float4 vertexColor : COLOR; + float2 texcoord : TEXCOORD0; + UNITY_VERTEX_INPUT_INSTANCE_ID +}; + +struct VaryingsSprite +{ + float4 positionCS : SV_POSITION; + float4 texcoordAndAlpha: TEXCOORD0; + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO +}; + +VaryingsSprite DepthOnlyVertexSprite(AttributesSprite input) +{ + VaryingsSprite output = (VaryingsSprite)0; + UNITY_SETUP_INSTANCE_ID(input); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + + output.texcoordAndAlpha.xyz = float3(TRANSFORM_TEX(input.texcoord, _MainTex).xy, 0); + output.texcoordAndAlpha.a = input.vertexColor.a * _Color.a; + output.positionCS = TransformObjectToHClip(input.positionOS.xyz); + return output; +} + +half4 DepthOnlyFragmentSprite(VaryingsSprite input) : SV_TARGET +{ + fixed4 texureColor = calculateTexturePixel(input.texcoordAndAlpha.xy); + clip(texureColor.a* input.texcoordAndAlpha.a - _Cutoff); + return 0; +} + +#endif diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-DepthOnlyPass-LW.hlsl.meta b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-DepthOnlyPass-LW.hlsl.meta new file mode 100644 index 000000000..e3aba800e --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-DepthOnlyPass-LW.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 59133a5e2cee2c845aadaf57d34067d2 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl index 0736f78b2..ece0c54b3 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl @@ -1,8 +1,8 @@ #ifndef VERTEX_LIT_FORWARD_PASS_LW_INCLUDED #define VERTEX_LIT_FORWARD_PASS_LW_INCLUDED +#include "CGIncludes/Spine-Sprite-Common-LW.hlsl" #include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Lighting.hlsl" - #include "SpineCoreShaders/SpriteLighting.cginc" //////////////////////////////////////// diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ShadowCasterPass-LW.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ShadowCasterPass-LW.hlsl index aa5e685c4..b1633ad24 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ShadowCasterPass-LW.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/Spine-Sprite-ShadowCasterPass-LW.hlsl @@ -1,9 +1,41 @@ #ifndef SPRITES_SHADOW_CASTER_PASS_LW_INCLUDED #define SPRITES_SHADOW_CASTER_PASS_LW_INCLUDED -#include "Spine-Common-ShadowCasterPass-LW.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" +#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Shadows.hlsl" -uniform fixed _ShadowAlphaCutoff; +float3 _LightDirection; + +struct AttributesSpine +{ + float4 positionOS : POSITION; + float3 normalOS : NORMAL; + float4 vertexColor : COLOR; + float2 texcoord : TEXCOORD0; + UNITY_VERTEX_INPUT_INSTANCE_ID +}; + +struct VaryingsSpine +{ + float4 positionCS : SV_POSITION; + float4 texcoordAndAlpha: TEXCOORD0; +}; + +float4 GetShadowPositionHClip(AttributesSpine input) +{ + float3 positionWS = TransformObjectToWorld(input.positionOS.xyz); + float3 normalWS = TransformObjectToWorldNormal(input.normalOS); + + float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection)); + +#if UNITY_REVERSED_Z + positionCS.z = min(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE); +#else + positionCS.z = max(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE); +#endif + + return positionCS; +} VaryingsSpine ShadowPassVertexSprite(AttributesSpine input) { @@ -16,10 +48,12 @@ VaryingsSpine ShadowPassVertexSprite(AttributesSpine input) return output; } +#include "SpineCoreShaders/ShaderShared.cginc" + half4 ShadowPassFragmentSprite(VaryingsSpine input) : SV_TARGET { fixed4 texureColor = calculateTexturePixel(input.texcoordAndAlpha.xy); - clip(texureColor.a * input.texcoordAndAlpha.a - _ShadowAlphaCutoff); + clip(texureColor.a* input.texcoordAndAlpha.a - _ShadowAlphaCutoff); return 0; } diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/SpineCoreShaders/Spine-Outline-Common.cginc b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/SpineCoreShaders/Spine-Outline-Common.cginc new file mode 100644 index 000000000..e0d1159e1 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/SpineCoreShaders/Spine-Outline-Common.cginc @@ -0,0 +1,2 @@ +// Adapt this path accordingly if you have unpacked the Spine directory to another location. +#include "Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc" diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/SpineCoreShaders/Spine-Outline-Common.cginc.meta b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/SpineCoreShaders/Spine-Outline-Common.cginc.meta new file mode 100644 index 000000000..b1c8b41fb --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/CGIncludes/SpineCoreShaders/Spine-Outline-Common.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 22b696908e97db04587317413f8b88b1 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-LWRP.shader b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-LW.shader similarity index 70% rename from spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-LWRP.shader rename to spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-LW.shader index 5590dc0f6..6cd892256 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-LWRP.shader +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-LW.shader @@ -29,7 +29,29 @@ Shader "Lightweight Render Pipeline/Spine/Outline/Skeleton-OutlineOnly" { Pass Keep } - UsePass "Spine/Outline/Skeleton/OUTLINE" + Pass { + Name "Outline" + HLSLPROGRAM + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + + #pragma vertex vertOutline + #pragma fragment fragOutline + #pragma shader_feature _ _USE8NEIGHBOURHOOD_ON + + #define USE_LWRP + #define fixed4 half4 + #define fixed3 half3 + #define fixed half + #include "../CGIncludes/Spine-Input-Outline-LW.hlsl" + #include "../CGIncludes/Spine-Outline-Pass-LW.hlsl" + ENDHLSL + } } FallBack "Hidden/InternalErrorShader" diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-LWRP.shader.meta b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-LW.shader.meta similarity index 100% rename from spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-LWRP.shader.meta rename to spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-LW.shader.meta diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-Skeleton-LW.shader b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-Skeleton-LW.shader index 5772003b4..c51008c31 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-Skeleton-LW.shader +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-Skeleton-LW.shader @@ -15,7 +15,7 @@ Shader "Lightweight Render Pipeline/Spine/Skeleton" { Cull Off ZWrite Off Blend One OneMinusSrcAlpha - + Stencil { Ref[_StencilRef] Comp[_StencilComp] @@ -42,7 +42,7 @@ Shader "Lightweight Render Pipeline/Spine/Skeleton" { #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE #pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS #pragma multi_compile _ _SHADOWS_SOFT - + // ------------------------------------- // Unity defined keywords #pragma multi_compile_fog @@ -60,13 +60,11 @@ Shader "Lightweight Render Pipeline/Spine/Skeleton" { #undef LIGHTMAP_ON - #include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl" - #include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Lighting.hlsl" - #define USE_LWRP #define fixed4 half4 #define fixed3 half3 #define fixed half + #include "CGIncludes/Spine-Input-LW.hlsl" #include "CGIncludes/Spine-Skeleton-ForwardPass-LW.hlsl" ENDHLSL } @@ -98,9 +96,6 @@ Shader "Lightweight Render Pipeline/Spine/Skeleton" { #pragma vertex ShadowPassVertexSkeletonLit #pragma fragment ShadowPassFragmentSkeletonLit - #include "Packages/com.unity.render-pipelines.lightweight/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.lightweight/Shaders/ShadowCasterPass.hlsl" - #define USE_LWRP #define fixed4 half4 #define fixed3 half3 @@ -126,8 +121,8 @@ Shader "Lightweight Render Pipeline/Spine/Skeleton" { #pragma exclude_renderers d3d11_9x #pragma target 2.0 - #pragma vertex DepthOnlyVertexSprite - #pragma fragment DepthOnlyFragmentSprite + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment // ------------------------------------- // Material Keywords @@ -138,9 +133,6 @@ Shader "Lightweight Render Pipeline/Spine/Skeleton" { // GPU Instancing #pragma multi_compile_instancing - #include "Packages/com.unity.render-pipelines.lightweight/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.lightweight/Shaders/DepthOnlyPass.hlsl" - #define USE_LWRP #define fixed4 half4 #define fixed3 half3 diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-SkeletonLit-LW.shader b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-SkeletonLit-LW.shader index f03856a19..ce7310448 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-SkeletonLit-LW.shader +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-SkeletonLit-LW.shader @@ -68,13 +68,11 @@ Shader "Lightweight Render Pipeline/Spine/Skeleton Lit" { #undef LIGHTMAP_ON - #include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl" - #include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Lighting.hlsl" - #define USE_LWRP #define fixed4 half4 #define fixed3 half3 #define fixed half + #include "CGIncludes/Spine-Input-LW.hlsl" #include "CGIncludes/Spine-SkeletonLit-ForwardPass-LW.hlsl" ENDHLSL } @@ -106,9 +104,6 @@ Shader "Lightweight Render Pipeline/Spine/Skeleton Lit" { #pragma vertex ShadowPassVertexSkeletonLit #pragma fragment ShadowPassFragmentSkeletonLit - #include "Packages/com.unity.render-pipelines.lightweight/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.lightweight/Shaders/ShadowCasterPass.hlsl" - #define USE_LWRP #define fixed4 half4 #define fixed3 half3 @@ -134,8 +129,8 @@ Shader "Lightweight Render Pipeline/Spine/Skeleton Lit" { #pragma exclude_renderers d3d11_9x #pragma target 2.0 - #pragma vertex DepthOnlyVertexSprite - #pragma fragment DepthOnlyFragmentSprite + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment // ------------------------------------- // Material Keywords @@ -146,9 +141,6 @@ Shader "Lightweight Render Pipeline/Spine/Skeleton Lit" { // GPU Instancing #pragma multi_compile_instancing - #include "Packages/com.unity.render-pipelines.lightweight/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.lightweight/Shaders/DepthOnlyPass.hlsl" - #define USE_LWRP #define fixed4 half4 #define fixed3 half3 diff --git a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-Sprite-LW.shader b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-Sprite-LW.shader index 6c9bb44db..94168970a 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-Sprite-LW.shader +++ b/spine-unity/Modules/com.esotericsoftware.spine.lwrp-shaders/Shaders/Spine-Sprite-LW.shader @@ -127,11 +127,7 @@ Shader "Lightweight Render Pipeline/Spine/Sprite" #define fixed4 half4 #define fixed3 half3 #define fixed half - - #include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl" - #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" - - #include "CGIncludes/Spine-Input-LW.hlsl" + #include "CGIncludes/Spine-Input-Sprite-LW.hlsl" #include "CGIncludes/Spine-Sprite-ForwardPass-LW.hlsl" ENDHLSL } @@ -163,14 +159,11 @@ Shader "Lightweight Render Pipeline/Spine/Sprite" #pragma vertex ShadowPassVertexSprite #pragma fragment ShadowPassFragmentSprite - #include "Packages/com.unity.render-pipelines.lightweight/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.lightweight/Shaders/ShadowCasterPass.hlsl" - #define USE_LWRP #define fixed4 half4 #define fixed3 half3 #define fixed half - #include "CGIncludes/Spine-Input-LW.hlsl" + #include "CGIncludes/Spine-Input-Sprite-LW.hlsl" #include "CGIncludes/Spine-Sprite-ShadowCasterPass-LW.hlsl" ENDHLSL } @@ -202,15 +195,12 @@ Shader "Lightweight Render Pipeline/Spine/Sprite" // GPU Instancing #pragma multi_compile_instancing - #include "Packages/com.unity.render-pipelines.lightweight/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.lightweight/Shaders/DepthOnlyPass.hlsl" - #define USE_LWRP #define fixed4 half4 #define fixed3 half3 #define fixed half - #include "CGIncludes/Spine-Input-LW.hlsl" - #include "CGIncludes/Spine-DepthOnlyPass-LW.hlsl" + #include "CGIncludes/Spine-Input-Sprite-LW.hlsl" + #include "CGIncludes/Spine-Sprite-DepthOnlyPass-LW.hlsl" ENDHLSL } } diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-Sprite-URP-2D.shader b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-Sprite-URP-2D.shader index d9f0ddbb9..11aae782e 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-Sprite-URP-2D.shader +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/2D/Spine-Sprite-URP-2D.shader @@ -104,6 +104,7 @@ Shader "Universal Render Pipeline/2D/Spine/Sprite" #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl" + #include "../Include/Spine-Input-Sprite-URP.hlsl" #include "Include/Spine-Sprite-StandardPass-URP-2D.hlsl" ENDHLSL } @@ -139,6 +140,7 @@ Shader "Universal Render Pipeline/2D/Spine/Sprite" #define fixed3 half3 #define fixed half + #include "../Include/Spine-Input-Sprite-URP.hlsl" #include "Include/Spine-Sprite-NormalsPass-URP-2D.hlsl" ENDHLSL diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Common-ShadowCasterPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Common-ShadowCasterPass-URP.hlsl index 43b6bdbf1..bf3efd88e 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Common-ShadowCasterPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Common-ShadowCasterPass-URP.hlsl @@ -1,7 +1,9 @@ #ifndef COMMON_SHADOW_CASTER_PASS_URP_INCLUDED #define COMMON_SHADOW_CASTER_PASS_URP_INCLUDED -#include "SpineCoreShaders/ShaderShared.cginc" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl" +float3 _LightDirection; struct AttributesSpine { diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-DepthOnlyPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-DepthOnlyPass-URP.hlsl index 34e7af782..e452ae44e 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-DepthOnlyPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-DepthOnlyPass-URP.hlsl @@ -1,40 +1,40 @@ #ifndef SPRITES_DEPTH_ONLY_PASS_URP_INCLUDED #define SPRITES_DEPTH_ONLY_PASS_URP_INCLUDED +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" -#include "SpineCoreShaders/ShaderShared.cginc" -struct AttributesSprite +struct AttributesSpine { float4 positionOS : POSITION; + float3 normalOS : NORMAL; float4 vertexColor : COLOR; float2 texcoord : TEXCOORD0; UNITY_VERTEX_INPUT_INSTANCE_ID }; -struct VaryingsSprite +struct VaryingsSpine { float4 positionCS : SV_POSITION; float4 texcoordAndAlpha: TEXCOORD0; - UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO }; -VaryingsSprite DepthOnlyVertexSprite(AttributesSprite input) +VaryingsSpine DepthOnlyVertex(AttributesSpine input) { - VaryingsSprite output = (VaryingsSprite)0; + VaryingsSpine output = (VaryingsSpine)0; UNITY_SETUP_INSTANCE_ID(input); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); output.texcoordAndAlpha.xyz = float3(TRANSFORM_TEX(input.texcoord, _MainTex).xy, 0); - output.texcoordAndAlpha.a = input.vertexColor.a * _Color.a; + output.texcoordAndAlpha.a = input.vertexColor.a; output.positionCS = TransformObjectToHClip(input.positionOS.xyz); return output; } -half4 DepthOnlyFragmentSprite(VaryingsSprite input) : SV_TARGET +half4 DepthOnlyFragment(VaryingsSpine input) : SV_TARGET { - fixed4 texureColor = calculateTexturePixel(input.texcoordAndAlpha.xy); + fixed4 texureColor = tex2D(_MainTex, input.texcoordAndAlpha.xy); clip(texureColor.a * input.texcoordAndAlpha.a - _Cutoff); return 0; } diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Outline-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Outline-URP.hlsl new file mode 100644 index 000000000..0c28b1e59 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Outline-URP.hlsl @@ -0,0 +1,26 @@ +#ifndef URP_INPUT_OUTLINE_INCLUDED +#define URP_INPUT_OUTLINE_INCLUDED + +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + +//////////////////////////////////////// +// Defines +// +#undef LIGHTMAP_ON + +CBUFFER_START(UnityPerMaterial) +float4 _MainTex_ST; +half _Cutoff; + +float _OutlineWidth; +float4 _OutlineColor; +float4 _MainTex_TexelSize; +float _ThresholdEnd; +float _OutlineSmoothness; +float _OutlineMipLevel; +int _OutlineReferenceTexWidth; +CBUFFER_END + +sampler2D _MainTex; + +#endif // URP_INPUT_OUTLINE_INCLUDED diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Outline-URP.hlsl.meta b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Outline-URP.hlsl.meta new file mode 100644 index 000000000..114e24762 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Outline-URP.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fbcfa8e1a739e2b4d9307f6c0980c50f +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Sprite-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Sprite-URP.hlsl new file mode 100644 index 000000000..3ab408a57 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Sprite-URP.hlsl @@ -0,0 +1,33 @@ +#ifndef URP_INPUT_SPRITE_INCLUDED +#define URP_INPUT_SPRITE_INCLUDED + +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + +CBUFFER_START(UnityPerMaterial) + +float4 _MainTex_ST; +half4 _Color; +half _Cutoff; +half _ShadowAlphaCutoff; + +half _Metallic; +half _Glossiness; +half _GlossMapScale; + +half _BumpScale; + +float _BlendAmount; + +float _Hue; +float _Saturation; +float _Brightness; +half4 _OverlayColor; + +half4 _EmissionColor; +float _EmissionPower; + +float4 _FixedNormal; + +CBUFFER_END + +#endif // URP_INPUT_SPRITE_INCLUDED diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Sprite-URP.hlsl.meta b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Sprite-URP.hlsl.meta new file mode 100644 index 000000000..0ec6d93c9 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-Sprite-URP.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7cb02894258b6c249ad73b7869086876 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-URP.hlsl index fdebde129..bb27ef3fb 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Input-URP.hlsl @@ -1,48 +1,18 @@ #ifndef URP_LIT_INPUT_INCLUDED #define URP_LIT_INPUT_INCLUDED +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + //////////////////////////////////////// // Defines // #undef LIGHTMAP_ON -#if defined(_SPECULAR) || defined(_SPECULAR_GLOSSMAP) -#define SPECULAR -#endif - -//Have to process lighting per pixel if using normal maps or a diffuse ramp or rim lighting or specular -#if defined(_NORMALMAP) || defined(_DIFFUSE_RAMP) || defined(_RIM_LIGHTING) || defined(SPECULAR) -#define PER_PIXEL_LIGHTING -#endif - -#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" -#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" -#include "SpineCoreShaders/ShaderShared.cginc" - -#if defined(SPECULAR) - CBUFFER_START(UnityPerMaterial) -half _Metallic; -half _Glossiness; -half _GlossMapScale; +float4 _MainTex_ST; +half _Cutoff; CBUFFER_END -sampler2D _MetallicGlossMap; - -inline half2 getMetallicGloss(float2 uv) -{ - half2 mg; - -#ifdef _SPECULAR_GLOSSMAP - mg = tex2D(_MetallicGlossMap, uv).ra; - mg.g *= _GlossMapScale; -#else - mg.r = _Metallic; - mg.g = _Glossiness; -#endif - - return mg; -} -#endif +sampler2D _MainTex; #endif // URP_LIT_INPUT_INCLUDED diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Outline-Pass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Outline-Pass-URP.hlsl new file mode 100644 index 000000000..126f87da5 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Outline-Pass-URP.hlsl @@ -0,0 +1,43 @@ +#ifndef SPINE_OUTLINE_PASS_URP_INCLUDED +#define SPINE_OUTLINE_PASS_URP_INCLUDED + +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" + +#include "SpineCoreShaders/Spine-Outline-Common.cginc" + +struct VertexInput { + float4 positionOS : POSITION; + float2 uv : TEXCOORD0; + float4 vertexColor : COLOR; + UNITY_VERTEX_INPUT_INSTANCE_ID +}; + +struct VertexOutput { + float4 pos : SV_POSITION; + float2 uv : TEXCOORD0; + float vertexColorAlpha : COLOR; + UNITY_VERTEX_OUTPUT_STEREO +}; + +VertexOutput vertOutline(VertexInput v) { + VertexOutput o; + + UNITY_SETUP_INSTANCE_ID(v); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); + + o.pos = TransformObjectToHClip(v.positionOS.xyz); + o.uv = v.uv; + o.vertexColorAlpha = v.vertexColor.a; + return o; +} + +float4 fragOutline(VertexOutput i) : SV_Target{ + + float4 texColor = computeOutlinePixel(_MainTex, _MainTex_TexelSize.xy, i.uv, i.vertexColorAlpha, + _OutlineWidth, _OutlineReferenceTexWidth, _OutlineMipLevel, + _OutlineSmoothness, _ThresholdEnd, _OutlineColor); + return texColor; +} + +#endif diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Outline-Pass-URP.hlsl.meta b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Outline-Pass-URP.hlsl.meta new file mode 100644 index 000000000..a23223100 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Outline-Pass-URP.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6702be883c5f0ef439d7d9ad87d0b84b +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Skeleton-ForwardPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Skeleton-ForwardPass-URP.hlsl index bb04f3341..d706aa849 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Skeleton-ForwardPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Skeleton-ForwardPass-URP.hlsl @@ -1,11 +1,14 @@ #ifndef SKELETON_FORWARD_PASS_URP_INCLUDED #define SKELETON_FORWARD_PASS_URP_INCLUDED +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" + struct appdata { float3 pos : POSITION; half4 color : COLOR; float2 uv0 : TEXCOORD0; - + UNITY_VERTEX_INPUT_INSTANCE_ID }; @@ -28,8 +31,6 @@ VertexOutput vert(appdata v) { return o; } -sampler2D _MainTex; - half4 frag(VertexOutput i) : SV_Target{ float4 texColor = tex2D(_MainTex, i.uv0); diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl index 0fd0c788c..02c0b6f37 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ForwardPass-URP.hlsl @@ -1,6 +1,10 @@ #ifndef SKELETONLIT_FORWARD_PASS_URP_INCLUDED #define SKELETONLIT_FORWARD_PASS_URP_INCLUDED +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + struct appdata { float3 pos : POSITION; float3 normal : NORMAL; @@ -66,8 +70,6 @@ VertexOutput vert(appdata v) { return o; } -sampler2D _MainTex; - half4 frag(VertexOutput i) : SV_Target{ half4 tex = tex2D(_MainTex, i.uv0); half4 col; diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ShadowCasterPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ShadowCasterPass-URP.hlsl index f3feb908a..453c1b4da 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ShadowCasterPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-SkeletonLit-ShadowCasterPass-URP.hlsl @@ -1,7 +1,42 @@ #ifndef SKELETONLIT_SHADOW_CASTER_PASS_URP_INCLUDED #define SKELETONLIT_SHADOW_CASTER_PASS_URP_INCLUDED -#include "Spine-Common-ShadowCasterPass-URP.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl" + +float3 _LightDirection; + +struct AttributesSpine +{ + float4 positionOS : POSITION; + float3 normalOS : NORMAL; + float4 vertexColor : COLOR; + float2 texcoord : TEXCOORD0; + UNITY_VERTEX_INPUT_INSTANCE_ID +}; + +struct VaryingsSpine +{ + float4 positionCS : SV_POSITION; + float4 texcoordAndAlpha: TEXCOORD0; +}; + +float4 GetShadowPositionHClip(AttributesSpine input) +{ + float3 positionWS = TransformObjectToWorld(input.positionOS.xyz); + float3 normalWS = TransformObjectToWorldNormal(input.normalOS); + + float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection)); + +#if UNITY_REVERSED_Z + positionCS.z = min(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE); +#else + positionCS.z = max(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE); +#endif + + return positionCS; +} VaryingsSpine ShadowPassVertexSkeletonLit(AttributesSpine input) { @@ -16,7 +51,7 @@ VaryingsSpine ShadowPassVertexSkeletonLit(AttributesSpine input) half4 ShadowPassFragmentSkeletonLit(VaryingsSpine input) : SV_TARGET { - fixed4 texureColor = calculateTexturePixel(input.texcoordAndAlpha.xy); + fixed4 texureColor = tex2D(_MainTex, input.texcoordAndAlpha.xy); clip(texureColor.a * input.texcoordAndAlpha.a - _Cutoff); return 0; } diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-Common-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-Common-URP.hlsl new file mode 100644 index 000000000..8d3f28bb3 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-Common-URP.hlsl @@ -0,0 +1,39 @@ +#ifndef URP_SPRITE_COMMON_INCLUDED +#define URP_SPRITE_COMMON_INCLUDED + +#undef LIGHTMAP_ON + +#if defined(_SPECULAR) || defined(_SPECULAR_GLOSSMAP) +#define SPECULAR +#endif + +//Have to process lighting per pixel if using normal maps or a diffuse ramp or rim lighting or specular +#if defined(_NORMALMAP) || defined(_DIFFUSE_RAMP) || defined(_RIM_LIGHTING) || defined(SPECULAR) +#define PER_PIXEL_LIGHTING +#endif + +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" +#include "SpineCoreShaders/ShaderShared.cginc" + +#if defined(SPECULAR) + +sampler2D _MetallicGlossMap; + +inline half2 getMetallicGloss(float2 uv) +{ + half2 mg; + +#ifdef _SPECULAR_GLOSSMAP + mg = tex2D(_MetallicGlossMap, uv).ra; + mg.g *= _GlossMapScale; +#else + mg.r = _Metallic; + mg.g = _Glossiness; +#endif + + return mg; +} +#endif + +#endif // URP_SPRITE_COMMON_INCLUDED diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-Common-URP.hlsl.meta b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-Common-URP.hlsl.meta new file mode 100644 index 000000000..1bf8b7f15 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-Common-URP.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 46ef6e1b09e1bc04885eb905a8f2822d +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthOnlyPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthOnlyPass-URP.hlsl new file mode 100644 index 000000000..c4bbb36d9 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthOnlyPass-URP.hlsl @@ -0,0 +1,42 @@ +#ifndef SPRITES_DEPTH_ONLY_PASS_URP_INCLUDED +#define SPRITES_DEPTH_ONLY_PASS_URP_INCLUDED + +#include "Include/Spine-Sprite-Common-URP.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + +struct AttributesSprite +{ + float4 positionOS : POSITION; + float4 vertexColor : COLOR; + float2 texcoord : TEXCOORD0; + UNITY_VERTEX_INPUT_INSTANCE_ID +}; + +struct VaryingsSprite +{ + float4 positionCS : SV_POSITION; + float4 texcoordAndAlpha: TEXCOORD0; + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO +}; + +VaryingsSprite DepthOnlyVertexSprite(AttributesSprite input) +{ + VaryingsSprite output = (VaryingsSprite)0; + UNITY_SETUP_INSTANCE_ID(input); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + + output.texcoordAndAlpha.xyz = float3(TRANSFORM_TEX(input.texcoord, _MainTex).xy, 0); + output.texcoordAndAlpha.a = input.vertexColor.a * _Color.a; + output.positionCS = TransformObjectToHClip(input.positionOS.xyz); + return output; +} + +half4 DepthOnlyFragmentSprite(VaryingsSprite input) : SV_TARGET +{ + fixed4 texureColor = calculateTexturePixel(input.texcoordAndAlpha.xy); + clip(texureColor.a * input.texcoordAndAlpha.a - _Cutoff); + return 0; +} + +#endif diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthOnlyPass-URP.hlsl.meta b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthOnlyPass-URP.hlsl.meta new file mode 100644 index 000000000..b3c0a6d41 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-DepthOnlyPass-URP.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9e6e6f2288b792e4aa0db167249e73bd +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl index 452389590..05448fa59 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl @@ -1,8 +1,8 @@ #ifndef VERTEX_LIT_FORWARD_PASS_URP_INCLUDED #define VERTEX_LIT_FORWARD_PASS_URP_INCLUDED +#include "Include/Spine-Sprite-Common-URP.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" - #include "SpineCoreShaders/SpriteLighting.cginc" #if defined(_RIM_LIGHTING) || defined(_ADDITIONAL_LIGHTS) || defined(MAIN_LIGHT_CALCULATE_SHADOWS) diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ShadowCasterPass-URP.hlsl b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ShadowCasterPass-URP.hlsl index ab7a6cbf0..d190c852b 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ShadowCasterPass-URP.hlsl +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ShadowCasterPass-URP.hlsl @@ -1,9 +1,41 @@ #ifndef SPRITES_SHADOW_CASTER_PASS_URP_INCLUDED #define SPRITES_SHADOW_CASTER_PASS_URP_INCLUDED -#include "Spine-Common-ShadowCasterPass-URP.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl" -uniform fixed _ShadowAlphaCutoff; +float3 _LightDirection; + +struct AttributesSpine +{ + float4 positionOS : POSITION; + float3 normalOS : NORMAL; + float4 vertexColor : COLOR; + float2 texcoord : TEXCOORD0; + UNITY_VERTEX_INPUT_INSTANCE_ID +}; + +struct VaryingsSpine +{ + float4 positionCS : SV_POSITION; + float4 texcoordAndAlpha: TEXCOORD0; +}; + +float4 GetShadowPositionHClip(AttributesSpine input) +{ + float3 positionWS = TransformObjectToWorld(input.positionOS.xyz); + float3 normalWS = TransformObjectToWorldNormal(input.normalOS); + + float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection)); + +#if UNITY_REVERSED_Z + positionCS.z = min(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE); +#else + positionCS.z = max(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE); +#endif + + return positionCS; +} VaryingsSpine ShadowPassVertexSprite(AttributesSpine input) { @@ -16,6 +48,8 @@ VaryingsSpine ShadowPassVertexSprite(AttributesSpine input) return output; } +#include "SpineCoreShaders/ShaderShared.cginc" + half4 ShadowPassFragmentSprite(VaryingsSpine input) : SV_TARGET { fixed4 texureColor = calculateTexturePixel(input.texcoordAndAlpha.xy); diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/Spine-Outline-Common.cginc b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/Spine-Outline-Common.cginc new file mode 100644 index 000000000..e0d1159e1 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/Spine-Outline-Common.cginc @@ -0,0 +1,2 @@ +// Adapt this path accordingly if you have unpacked the Spine directory to another location. +#include "Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Outline-Common.cginc" diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/Spine-Outline-Common.cginc.meta b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/Spine-Outline-Common.cginc.meta new file mode 100644 index 000000000..afad6a8a0 --- /dev/null +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/SpineCoreShaders/Spine-Outline-Common.cginc.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 13cee1d5ffe7f304a9f5ff15ef07c3bc +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-URP.shader b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-URP.shader index 5f4edcfcb..573e51146 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-URP.shader +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Outline/Spine-Skeleton-OutlineOnly-URP.shader @@ -29,7 +29,29 @@ Shader "Universal Render Pipeline/Spine/Outline/Skeleton-OutlineOnly" { Pass Keep } - UsePass "Spine/Outline/Skeleton/OUTLINE" + Pass { + Name "Outline" + HLSLPROGRAM + // Required to compile gles 2.0 with standard srp library + #pragma prefer_hlslcc gles + #pragma exclude_renderers d3d11_9x + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + + #pragma vertex vertOutline + #pragma fragment fragOutline + #pragma shader_feature _ _USE8NEIGHBOURHOOD_ON + + #define USE_URP + #define fixed4 half4 + #define fixed3 half3 + #define fixed half + #include "../Include/Spine-Input-Outline-URP.hlsl" + #include "../Include/Spine-Outline-Pass-URP.hlsl" + ENDHLSL + } } FallBack "Hidden/InternalErrorShader" diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Skeleton-URP.shader b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Skeleton-URP.shader index 20677a848..e09e4a368 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Skeleton-URP.shader +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Skeleton-URP.shader @@ -58,13 +58,11 @@ Shader "Universal Render Pipeline/Spine/Skeleton" { #undef LIGHTMAP_ON - #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" - #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" - #define USE_URP #define fixed4 half4 #define fixed3 half3 #define fixed half + #include "Include/Spine-Input-URP.hlsl" #include "Include/Spine-Skeleton-ForwardPass-URP.hlsl" ENDHLSL } @@ -96,9 +94,6 @@ Shader "Universal Render Pipeline/Spine/Skeleton" { #pragma vertex ShadowPassVertexSkeletonLit #pragma fragment ShadowPassFragmentSkeletonLit - #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" - #define USE_URP #define fixed4 half4 #define fixed3 half3 @@ -123,8 +118,8 @@ Shader "Universal Render Pipeline/Spine/Skeleton" { #pragma prefer_hlslcc gles #pragma exclude_renderers d3d11_9x - #pragma vertex DepthOnlyVertexSprite - #pragma fragment DepthOnlyFragmentSprite + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment // ------------------------------------- // Material Keywords @@ -135,9 +130,6 @@ Shader "Universal Render Pipeline/Spine/Skeleton" { // GPU Instancing #pragma multi_compile_instancing - #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" - #define USE_URP #define fixed4 half4 #define fixed3 half3 diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-SkeletonLit-URP.shader b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-SkeletonLit-URP.shader index f8328d65d..b9d07e1cf 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-SkeletonLit-URP.shader +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-SkeletonLit-URP.shader @@ -62,13 +62,11 @@ #undef LIGHTMAP_ON - #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" - #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" - #define USE_URP #define fixed4 half4 #define fixed3 half3 #define fixed half + #include "Include/Spine-Input-URP.hlsl" #include "Include/Spine-SkeletonLit-ForwardPass-URP.hlsl" ENDHLSL } @@ -100,9 +98,6 @@ #pragma vertex ShadowPassVertexSkeletonLit #pragma fragment ShadowPassFragmentSkeletonLit - #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" - #define USE_URP #define fixed4 half4 #define fixed3 half3 @@ -113,7 +108,7 @@ ENDHLSL } - Pass + Pass { Name "DepthOnly" Tags{"LightMode" = "DepthOnly"} @@ -127,8 +122,8 @@ #pragma prefer_hlslcc gles #pragma exclude_renderers d3d11_9x - #pragma vertex DepthOnlyVertexSprite - #pragma fragment DepthOnlyFragmentSprite + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment // ------------------------------------- // Material Keywords @@ -139,9 +134,6 @@ // GPU Instancing #pragma multi_compile_instancing - #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" - #define USE_URP #define fixed4 half4 #define fixed3 half3 diff --git a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader index f40e5098b..ba688f14f 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader +++ b/spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader @@ -128,11 +128,7 @@ Shader "Universal Render Pipeline/Spine/Sprite" #define fixed4 half4 #define fixed3 half3 #define fixed half - - #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" - #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" - - #include "Include/Spine-Input-URP.hlsl" + #include "Include/Spine-Input-Sprite-URP.hlsl" #include "Include/Spine-Sprite-ForwardPass-URP.hlsl" ENDHLSL } @@ -164,14 +160,11 @@ Shader "Universal Render Pipeline/Spine/Sprite" #pragma vertex ShadowPassVertexSprite #pragma fragment ShadowPassFragmentSprite - #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" - #define USE_URP #define fixed4 half4 #define fixed3 half3 #define fixed half - #include "Include/Spine-Input-URP.hlsl" + #include "Include/Spine-Input-Sprite-URP.hlsl" #include "Include/Spine-Sprite-ShadowCasterPass-URP.hlsl" ENDHLSL } @@ -202,15 +195,12 @@ Shader "Universal Render Pipeline/Spine/Sprite" // GPU Instancing #pragma multi_compile_instancing - #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl" - #define USE_URP #define fixed4 half4 #define fixed3 half3 #define fixed half - #include "Include/Spine-Input-URP.hlsl" - #include "Include/Spine-DepthOnlyPass-URP.hlsl" + #include "Include/Spine-Input-Sprite-URP.hlsl" + #include "Include/Spine-Sprite-DepthOnlyPass-URP.hlsl" ENDHLSL } }