mirror of
https://projects.caleb-brown.dev/UDRI-XRT/UDRIGEEKCup2024.git
synced 2025-01-22 15:18:25 -05:00
83 lines
2.5 KiB
Plaintext
83 lines
2.5 KiB
Plaintext
Shader "URP Shadow Receiver"
|
|
{
|
|
Properties
|
|
{
|
|
_ShadowColor ("Shadow Color", Color) = (0.35, 0.4, 0.45, 1.0)
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags
|
|
{
|
|
"RenderPipeline" = "UniversalPipeline"
|
|
"RenderType" = "Transparent"
|
|
"Queue" = "Transparent-1"
|
|
}
|
|
|
|
Pass
|
|
{
|
|
Name "ForwardLit"
|
|
|
|
Tags
|
|
{
|
|
"LightMode" = "UniversalForward"
|
|
}
|
|
|
|
Blend DstColor Zero, Zero One
|
|
Cull Back
|
|
ZTest LEqual
|
|
ZWrite Off
|
|
|
|
HLSLPROGRAM
|
|
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma prefer_hlslcc gles
|
|
#pragma exclude_renderers d3d11_9x
|
|
#pragma target 2.0
|
|
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
|
#pragma multi_compile _ _SHADOWS_SOFT
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
|
|
|
CBUFFER_START(UnityPerMaterial)
|
|
float4 _ShadowColor;
|
|
CBUFFER_END
|
|
|
|
struct Attributes
|
|
{
|
|
half4 positionOS : POSITION;
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
half4 positionCS : SV_POSITION;
|
|
half3 positionWS : TEXCOORD0;
|
|
};
|
|
|
|
Varyings vert(Attributes input)
|
|
{
|
|
Varyings output;
|
|
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
|
output.positionCS = vertexInput.positionCS;
|
|
output.positionWS = vertexInput.positionWS;
|
|
return output;
|
|
}
|
|
|
|
half4 frag(Varyings input) : SV_Target
|
|
{
|
|
half4 color = half4(1, 1, 1, 1);
|
|
#if (defined(_MAIN_LIGHT_SHADOWS) || defined(_MAIN_LIGHT_SHADOWS_CASCADE) || defined(_MAIN_LIGHT_SHADOWS_SCREEN))
|
|
VertexPositionInputs vertexInput = (VertexPositionInputs)0;
|
|
vertexInput.positionWS = input.positionWS;
|
|
float4 shadowCoord = GetShadowCoord(vertexInput);
|
|
half shadowAttenutation = MainLightRealtimeShadow(shadowCoord);
|
|
color = lerp(half4(1, 1, 1, 1), _ShadowColor, (1.0 - shadowAttenutation) * _ShadowColor.a);
|
|
#endif
|
|
return color;
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
}
|
|
}
|