mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-06 10:46:53 +08:00
[unity] Fixed URP lit shaders ignoring straight alpha settings during fallback to unlit. Affected SkeletonRenderTexture. Closes #2044.
This commit is contained in:
parent
6d4b8e68bc
commit
5a32e002b8
@ -0,0 +1,47 @@
|
|||||||
|
#ifndef SKELETONLIT_UNLIT_PASS_INCLUDED
|
||||||
|
#define SKELETONLIT_UNLIT_PASS_INCLUDED
|
||||||
|
|
||||||
|
struct Attributes
|
||||||
|
{
|
||||||
|
float3 positionOS : POSITION;
|
||||||
|
float4 color : COLOR;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Varyings
|
||||||
|
{
|
||||||
|
float4 positionCS : SV_POSITION;
|
||||||
|
float4 color : COLOR;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEXTURE2D(_MainTex);
|
||||||
|
SAMPLER(sampler_MainTex);
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
|
||||||
|
Varyings UnlitVertex(Attributes attributes)
|
||||||
|
{
|
||||||
|
Varyings o = (Varyings)0;
|
||||||
|
|
||||||
|
o.positionCS = TransformObjectToHClip(attributes.positionOS);
|
||||||
|
o.uv = TRANSFORM_TEX(attributes.uv, _MainTex);
|
||||||
|
o.uv = attributes.uv;
|
||||||
|
o.color = attributes.color;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 UnlitFragment(Varyings i) : SV_Target
|
||||||
|
{
|
||||||
|
half4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||||
|
half4 main;
|
||||||
|
#if defined(_STRAIGHT_ALPHA_INPUT)
|
||||||
|
main.rgb = tex.rgb * i.color.rgb * tex.a;
|
||||||
|
#else
|
||||||
|
main.rgb = tex.rgb * i.color.rgb;
|
||||||
|
#endif
|
||||||
|
main.a = tex.a * i.color.a;
|
||||||
|
|
||||||
|
return main;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 580dd7e812fc63c4a9330abe519946de
|
||||||
|
ShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
defaultTextures: []
|
||||||
|
nonModifiableTextures: []
|
||||||
|
preprocessorOverride: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -193,52 +193,12 @@
|
|||||||
Blend One OneMinusSrcAlpha
|
Blend One OneMinusSrcAlpha
|
||||||
|
|
||||||
HLSLPROGRAM
|
HLSLPROGRAM
|
||||||
|
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||||
#pragma prefer_hlslcc gles
|
#pragma prefer_hlslcc gles
|
||||||
#pragma vertex UnlitVertex
|
#pragma vertex UnlitVertex
|
||||||
#pragma fragment UnlitFragment
|
#pragma fragment UnlitFragment
|
||||||
|
|
||||||
struct Attributes
|
#include "Include/Spine-SkeletonLit-UnlitPass-URP-2D.hlsl"
|
||||||
{
|
|
||||||
float3 positionOS : POSITION;
|
|
||||||
float4 color : COLOR;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Varyings
|
|
||||||
{
|
|
||||||
float4 positionCS : SV_POSITION;
|
|
||||||
float4 color : COLOR;
|
|
||||||
float2 uv : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
TEXTURE2D(_MainTex);
|
|
||||||
SAMPLER(sampler_MainTex);
|
|
||||||
float4 _MainTex_ST;
|
|
||||||
|
|
||||||
Varyings UnlitVertex(Attributes attributes)
|
|
||||||
{
|
|
||||||
Varyings o = (Varyings)0;
|
|
||||||
|
|
||||||
o.positionCS = TransformObjectToHClip(attributes.positionOS);
|
|
||||||
o.uv = TRANSFORM_TEX(attributes.uv, _MainTex);
|
|
||||||
o.uv = attributes.uv;
|
|
||||||
o.color = attributes.color;
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
float4 UnlitFragment(Varyings i) : SV_Target
|
|
||||||
{
|
|
||||||
half4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
|
||||||
half4 main;
|
|
||||||
#if defined(_STRAIGHT_ALPHA_INPUT)
|
|
||||||
main.rgb = tex.rgb * i.color.rgb * tex.a;
|
|
||||||
#else
|
|
||||||
main.rgb = tex.rgb * i.color.rgb;
|
|
||||||
#endif
|
|
||||||
main.a = tex.a * i.color.a;
|
|
||||||
|
|
||||||
return main;
|
|
||||||
}
|
|
||||||
ENDHLSL
|
ENDHLSL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -147,7 +147,28 @@ Shader "Universal Render Pipeline/2D/Spine/Sprite"
|
|||||||
ENDHLSL
|
ENDHLSL
|
||||||
}
|
}
|
||||||
|
|
||||||
UsePass "Universal Render Pipeline/2D/Spine/Skeleton Lit/UNLIT"
|
Pass
|
||||||
|
{
|
||||||
|
Name "Unlit"
|
||||||
|
Tags { "LightMode" = "UniversalForward" "Queue" = "Transparent" "RenderType" = "Transparent"}
|
||||||
|
|
||||||
|
ZWrite Off
|
||||||
|
Cull Off
|
||||||
|
Blend One OneMinusSrcAlpha
|
||||||
|
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAPREMULTIPLY_VERTEX_ONLY _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
|
||||||
|
#if defined(_ALPHAPREMULTIPLY_VERTEX_ONLY) || defined(_ALPHABLEND_ON)
|
||||||
|
#define _STRAIGHT_ALPHA_INPUT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma prefer_hlslcc gles
|
||||||
|
#pragma vertex UnlitVertex
|
||||||
|
#pragma fragment UnlitFragment
|
||||||
|
|
||||||
|
#include "Include/Spine-SkeletonLit-UnlitPass-URP-2D.hlsl"
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FallBack "Universal Render Pipeline/2D/Spine/Skeleton Lit"
|
FallBack "Universal Render Pipeline/2D/Spine/Skeleton Lit"
|
||||||
|
|||||||
@ -113,7 +113,7 @@ Shader "Universal Render Pipeline/Spine/Sprite"
|
|||||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||||
#pragma multi_compile _ LIGHTMAP_ON
|
#pragma multi_compile _ LIGHTMAP_ON
|
||||||
|
|
||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
// GPU Instancing
|
// GPU Instancing
|
||||||
#pragma multi_compile_instancing
|
#pragma multi_compile_instancing
|
||||||
|
|
||||||
@ -202,6 +202,36 @@ Shader "Universal Render Pipeline/Spine/Sprite"
|
|||||||
#include "Include/Spine-Sprite-DepthOnlyPass-URP.hlsl"
|
#include "Include/Spine-Sprite-DepthOnlyPass-URP.hlsl"
|
||||||
ENDHLSL
|
ENDHLSL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "Unlit"
|
||||||
|
Tags { "LightMode" = "UniversalForward" "Queue" = "Transparent" "RenderType" = "Transparent"}
|
||||||
|
|
||||||
|
ZWrite Off
|
||||||
|
Cull Off
|
||||||
|
Blend One OneMinusSrcAlpha
|
||||||
|
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAPREMULTIPLY_VERTEX_ONLY _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
|
||||||
|
#if defined(_ALPHAPREMULTIPLY_VERTEX_ONLY) || defined(_ALPHABLEND_ON)
|
||||||
|
#define _STRAIGHT_ALPHA_INPUT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma prefer_hlslcc gles
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
|
||||||
|
#undef LIGHTMAP_ON
|
||||||
|
|
||||||
|
#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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FallBack "Hidden/InternalErrorShader"
|
FallBack "Hidden/InternalErrorShader"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user