You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HighGroundRoyaleNetcode/Assets/OutlineURP2.shader

65 lines
1.7 KiB
Plaintext

Shader "Custom/OutlineURP"
{
Properties
{
_OutlineColor ("Outline Color", Color) = (1, 1, 0, 1)
_OutlineWidth ("Outline Width", Range(0.0, 0.05)) = 0.01
}
SubShader
{
Tags { "RenderType"="Opaque" "Queue"="Overlay" }
Pass
{
Name "Outline"
Tags { "LightMode"="UniversalForward" }
Cull Front // Render back faces for outline
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
};
float4 _OutlineColor;
float _OutlineWidth;
Varyings vert(Attributes IN)
{
Varyings OUT;
// Convert object-space normal to world-space
float3 normalWS = TransformObjectToWorldNormal(IN.normalOS);
// Convert object-space position to world-space
float3 positionWS = TransformObjectToWorld(IN.positionOS);
// Expand the model along its normals for outline effect
positionWS += normalWS * _OutlineWidth;
// Convert world-space position to clip-space
OUT.positionCS = TransformWorldToHClip(positionWS);
return OUT;
}
half4 frag(Varyings IN) : SV_Target
{
return _OutlineColor; // Use user-defined outline color
}
ENDHLSL
}
}
}