mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[unity] Fixed "Universal Render Pipeline/Spine/Skeleton Lit" shader ignoring fog. Closes #2959.
This commit is contained in:
parent
990ff34747
commit
49abbdc458
@ -16,6 +16,10 @@
|
|||||||
#define USE_ADAPTIVE_PROBE_VOLUMES
|
#define USE_ADAPTIVE_PROBE_VOLUMES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2)
|
||||||
|
#define _FOG
|
||||||
|
#endif
|
||||||
|
|
||||||
struct appdata {
|
struct appdata {
|
||||||
float3 pos : POSITION;
|
float3 pos : POSITION;
|
||||||
float3 normal : NORMAL;
|
float3 normal : NORMAL;
|
||||||
@ -30,7 +34,11 @@ struct appdata {
|
|||||||
|
|
||||||
struct VertexOutput {
|
struct VertexOutput {
|
||||||
half4 color : COLOR0;
|
half4 color : COLOR0;
|
||||||
|
#if defined(_FOG)
|
||||||
|
float3 uv0AndFog : TEXCOORD0;
|
||||||
|
#else
|
||||||
float2 uv0 : TEXCOORD0;
|
float2 uv0 : TEXCOORD0;
|
||||||
|
#endif
|
||||||
float4 pos : SV_POSITION;
|
float4 pos : SV_POSITION;
|
||||||
|
|
||||||
#if defined(SKELETONLIT_RECEIVE_SHADOWS)
|
#if defined(SKELETONLIT_RECEIVE_SHADOWS)
|
||||||
@ -50,6 +58,13 @@ struct VertexOutput {
|
|||||||
UNITY_VERTEX_OUTPUT_STEREO
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(_FOG)
|
||||||
|
#define PackedUV0(i) i.uv0AndFog.xy
|
||||||
|
#define PackedFog(i) i.uv0AndFog.z
|
||||||
|
#else
|
||||||
|
#define PackedUV0(i) i.uv0.xy
|
||||||
|
#endif
|
||||||
|
|
||||||
half3 ProcessLight(float3 positionWS, half3 normalWS, uint meshRenderingLayers, int lightIndex)
|
half3 ProcessLight(float3 positionWS, half3 normalWS, uint meshRenderingLayers, int lightIndex)
|
||||||
{
|
{
|
||||||
Light light = GetAdditionalLight(lightIndex, positionWS);
|
Light light = GetAdditionalLight(lightIndex, positionWS);
|
||||||
@ -116,8 +131,13 @@ VertexOutput vert(appdata v) {
|
|||||||
float3 positionWS = TransformObjectToWorld(v.pos);
|
float3 positionWS = TransformObjectToWorld(v.pos);
|
||||||
half3 fixedNormal = half3(0, 0, -1);
|
half3 fixedNormal = half3(0, 0, -1);
|
||||||
half3 normalWS = normalize(mul((float3x3)unity_ObjectToWorld, fixedNormal));
|
half3 normalWS = normalize(mul((float3x3)unity_ObjectToWorld, fixedNormal));
|
||||||
o.uv0 = v.uv0;
|
|
||||||
o.pos = TransformWorldToHClip(positionWS);
|
o.pos = TransformWorldToHClip(positionWS);
|
||||||
|
#if defined(_FOG)
|
||||||
|
half fogFactor = ComputeFogFactor(o.pos.z);
|
||||||
|
PackedFog(o) = fogFactor;
|
||||||
|
#endif
|
||||||
|
PackedUV0(o) = v.uv0;
|
||||||
|
|
||||||
#ifdef _DOUBLE_SIDED_LIGHTING
|
#ifdef _DOUBLE_SIDED_LIGHTING
|
||||||
// unfortunately we have to compute the sign here in the vertex shader
|
// unfortunately we have to compute the sign here in the vertex shader
|
||||||
@ -207,7 +227,7 @@ half4 frag(VertexOutput i
|
|||||||
#endif
|
#endif
|
||||||
) : SV_Target0
|
) : SV_Target0
|
||||||
{
|
{
|
||||||
half4 tex = tex2D(_MainTex, i.uv0);
|
half4 tex = tex2D(_MainTex, PackedUV0(i));
|
||||||
#if !defined(_TINT_BLACK_ON) && defined(_STRAIGHT_ALPHA_INPUT)
|
#if !defined(_TINT_BLACK_ON) && defined(_STRAIGHT_ALPHA_INPUT)
|
||||||
tex.rgb *= tex.a;
|
tex.rgb *= tex.a;
|
||||||
#endif
|
#endif
|
||||||
@ -256,10 +276,15 @@ half4 frag(VertexOutput i
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_TINT_BLACK_ON)
|
#if defined(_TINT_BLACK_ON)
|
||||||
return fragTintedColor(tex, i.darkColor, i.color, _Color.a, _Black.a);
|
half4 pixel = fragTintedColor(tex, i.darkColor, i.color, _Color.a, _Black.a);
|
||||||
#else
|
#else
|
||||||
return tex * i.color;
|
half4 pixel = tex * i.color;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_FOG)
|
||||||
|
pixel.rgb = MixFogColor(pixel.rgb, unity_FogColor.rgb * pixel.a, PackedFog(i));
|
||||||
|
#endif
|
||||||
|
return pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "com.esotericsoftware.spine.urp-shaders",
|
"name": "com.esotericsoftware.spine.urp-shaders",
|
||||||
"displayName": "Spine Universal RP Shaders",
|
"displayName": "Spine Universal RP Shaders",
|
||||||
"description": "This plugin provides universal render pipeline (URP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.2.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
|
"description": "This plugin provides universal render pipeline (URP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.2.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
|
||||||
"version": "4.2.47",
|
"version": "4.2.48",
|
||||||
"unity": "2019.3",
|
"unity": "2019.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Esoteric Software",
|
"name": "Esoteric Software",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user