93 lines
2.8 KiB
Plaintext
93 lines
2.8 KiB
Plaintext
Shader "The Decline Of Warriors/Radius Reveal Unlit"
|
|
{
|
|
Properties
|
|
{
|
|
_BaseMap("Base Map", 2D) = "white" {}
|
|
_BaseColor("Base Color", Color) = (1, 1, 1, 1)
|
|
_RevealRadius("Reveal Radius", Float) = 6
|
|
_EdgeSoftness("Edge Softness", Float) = 1
|
|
_Alpha("Alpha", Range(0, 1)) = 1
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags
|
|
{
|
|
"RenderType"="Transparent"
|
|
"Queue"="Transparent"
|
|
"RenderPipeline"="UniversalPipeline"
|
|
}
|
|
|
|
Pass
|
|
{
|
|
Name "RadiusReveal"
|
|
Tags { "LightMode"="UniversalForward" }
|
|
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
Cull Back
|
|
ZWrite Off
|
|
ZTest Always
|
|
|
|
HLSLPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma target 2.0
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
|
|
TEXTURE2D(_BaseMap);
|
|
SAMPLER(sampler_BaseMap);
|
|
|
|
CBUFFER_START(UnityPerMaterial)
|
|
float4 _BaseMap_ST;
|
|
half4 _BaseColor;
|
|
float _RevealRadius;
|
|
float _EdgeSoftness;
|
|
float _Alpha;
|
|
CBUFFER_END
|
|
|
|
float4 _RevealCenter;
|
|
float _GlobalRevealRadius;
|
|
float _GlobalRevealEdgeSoftness;
|
|
|
|
struct Attributes
|
|
{
|
|
float4 positionOS : POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
float4 positionHCS : SV_POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
float3 positionWS : TEXCOORD1;
|
|
};
|
|
|
|
Varyings vert(Attributes input)
|
|
{
|
|
Varyings output;
|
|
VertexPositionInputs positionInputs = GetVertexPositionInputs(input.positionOS.xyz);
|
|
output.positionHCS = positionInputs.positionCS;
|
|
output.positionWS = positionInputs.positionWS;
|
|
output.uv = TRANSFORM_TEX(input.uv, _BaseMap);
|
|
return output;
|
|
}
|
|
|
|
half4 frag(Varyings input) : SV_Target
|
|
{
|
|
float radius = _GlobalRevealRadius > 0.0 ? _GlobalRevealRadius : _RevealRadius;
|
|
float softness = _GlobalRevealEdgeSoftness > 0.0 ? _GlobalRevealEdgeSoftness : _EdgeSoftness;
|
|
float distanceToCenter = distance(input.positionWS, _RevealCenter.xyz);
|
|
float mask = 1.0 - smoothstep(radius - softness, radius, distanceToCenter);
|
|
|
|
clip(mask - 0.001);
|
|
|
|
half4 albedo = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv) * _BaseColor;
|
|
albedo.a *= mask * _Alpha;
|
|
return albedo;
|
|
}
|
|
ENDHLSL
|
|
}
|
|
}
|
|
}
|