Skip to content

Commit

Permalink
[unity] Fixed Universal Render Pipeline/2D/Spine/Sprite normals bei…
Browse files Browse the repository at this point in the history
…ng incorrect in transparent areas. Closes #1588.
  • Loading branch information
HaraldCsaszar committed Jan 2, 2020
1 parent a297e7f commit 3a255ab
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 51 deletions.
Expand Up @@ -170,46 +170,50 @@
}

Pass
{
{
Name "Unlit"
Tags { "LightMode" = "UniversalForward" "Queue"="Transparent" "RenderType"="Transparent"}

HLSLPROGRAM
#pragma prefer_hlslcc gles
#pragma vertex UnlitVertex
#pragma fragment UnlitFragment

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
{
Tags { "LightMode" = "UniversalForward" "Queue"="Transparent" "RenderType"="Transparent"}

ZWrite Off
Cull Off
Blend One OneMinusSrcAlpha

HLSLPROGRAM
#pragma prefer_hlslcc gles
#pragma vertex UnlitVertex
#pragma fragment UnlitFragment

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)
Expand All @@ -219,10 +223,10 @@
#endif
main.a = tex.a * i.color.a;

return main;
}
ENDHLSL
}
return main;
}
ENDHLSL
}
}
FallBack "Universal Render Pipeline/2D/Sprite-Lit-Default"
}
Expand Up @@ -111,12 +111,15 @@ Shader "Universal Render Pipeline/2D/Spine/Sprite"
}

Pass
{
Tags { "LightMode" = "NormalsRendering"}
HLSLPROGRAM
#pragma prefer_hlslcc gles
#pragma vertex NormalsRenderingVertex
#pragma fragment NormalsRenderingFragment
{
Tags { "LightMode" = "NormalsRendering"}

Blend SrcAlpha OneMinusSrcAlpha

HLSLPROGRAM
#pragma prefer_hlslcc gles
#pragma vertex NormalsRenderingVertex
#pragma fragment NormalsRenderingFragment

// -------------------------------------
// Material Keywords
Expand All @@ -138,8 +141,8 @@ Shader "Universal Render Pipeline/2D/Spine/Sprite"

#include "Include/Spine-Sprite-NormalsPass-URP-2D.hlsl"

ENDHLSL
}
ENDHLSL
}

UsePass "Universal Render Pipeline/2D/Spine/Skeleton Lit/UNLIT"
}
Expand Down

0 comments on commit 3a255ab

Please sign in to comment.