77 lines
1.8 KiB
Plaintext
77 lines
1.8 KiB
Plaintext
Shader "URP_Test/PostOutline_3"
|
|
{
|
|
Properties
|
|
{
|
|
_MainTex ("Texture", 2D) = "white" {}
|
|
}
|
|
SubShader
|
|
{
|
|
Tags
|
|
{
|
|
"RenderType"="Opaque"
|
|
"RenderPipeline" = "UniversalPipeline"
|
|
}
|
|
|
|
Cull Off
|
|
ZWrite Off
|
|
ZTest Off
|
|
|
|
Pass
|
|
{
|
|
Name "DoMerge"
|
|
// 合并
|
|
HLSLPROGRAM
|
|
#pragma vertex VERT
|
|
#pragma fragment FRAG
|
|
#pragma target 2.0
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
|
|
CBUFFER_START(UnityPerMaterial)
|
|
|
|
float4 _MainTex_TexelSize;
|
|
float4 _EdgeTex_TexelSize;
|
|
|
|
CBUFFER_END
|
|
|
|
TEXTURE2D(_MainTex);
|
|
SAMPLER(sampler_MainTex);
|
|
|
|
TEXTURE2D(_EdgeTex);
|
|
SAMPLER(sampler_EdgeTex);
|
|
|
|
struct a2v
|
|
{
|
|
float4 positionOS : POSITION;
|
|
float2 uv0 : TEXCOORD;
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 positionCS : SV_POSITION;
|
|
float4 texcoord0 : TEXCOORD0;
|
|
};
|
|
|
|
v2f VERT(a2v i)
|
|
{
|
|
v2f o;
|
|
o.positionCS = TransformObjectToHClip(i.positionOS.xyz);
|
|
o.texcoord0 = float4(i.uv0, 0, 0);
|
|
return o;
|
|
}
|
|
|
|
half4 FRAG(v2f i):SV_TARGET
|
|
{
|
|
half4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord0.xy);
|
|
half4 outlineCol = SAMPLE_TEXTURE2D(_EdgeTex, sampler_EdgeTex, i.texcoord0.xy);
|
|
if (outlineCol.a < 0.5) {
|
|
return col;
|
|
}
|
|
return outlineCol * outlineCol.a + col * (1 - outlineCol.a);
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
}
|
|
}
|