122 lines
3.3 KiB
Plaintext
122 lines
3.3 KiB
Plaintext
Shader "Lux URP/Depth Only"
|
|
{
|
|
Properties
|
|
{
|
|
[Header(Surface Options)]
|
|
[Space(5)]
|
|
[Toggle(_ALPHATEST_ON)]
|
|
_AlphaClip ("Alpha Clipping", Float) = 0.0
|
|
_Cutoff (" Threshold", Range(0.0, 1.0)) = 0.5
|
|
|
|
[Header(Surface Inputs)]
|
|
[Space(5)]
|
|
[MainTexture]
|
|
_BaseMap ("Albedo (RGB) Alpha (A)", 2D) = "white" {}
|
|
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags
|
|
{
|
|
"RenderPipeline" = "UniversalPipeline"
|
|
"RenderType" = "Opaque"
|
|
"Queue" = "Geometry"
|
|
}
|
|
LOD 100
|
|
|
|
|
|
// Depth -----------------------------------------------------
|
|
// Pass needed to receive proper shadows
|
|
|
|
Pass
|
|
{
|
|
Tags{"LightMode" = "DepthOnly"}
|
|
|
|
ZWrite On
|
|
ColorMask 0
|
|
Cull Off
|
|
|
|
HLSLPROGRAM
|
|
// Required to compile gles 2.0 with standard srp library
|
|
#pragma prefer_hlslcc gles
|
|
#pragma exclude_renderers d3d11_9x
|
|
#pragma target 2.0
|
|
|
|
#pragma vertex DepthOnlyVertex
|
|
#pragma fragment DepthOnlyFragment
|
|
|
|
// -------------------------------------
|
|
// Material Keywords
|
|
#pragma shader_feature _ALPHATEST_ON
|
|
|
|
//--------------------------------------
|
|
// GPU Instancing
|
|
#pragma multi_compile_instancing
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
|
|
// Material Inputs
|
|
CBUFFER_START(UnityPerMaterial)
|
|
half _Cutoff;
|
|
CBUFFER_END
|
|
|
|
#if defined(_ALPHATEST_ON)
|
|
TEXTURE2D(_BaseMap); SAMPLER(sampler_BaseMap);
|
|
#endif
|
|
|
|
|
|
|
|
struct VertexInput {
|
|
float3 positionOS : POSITION;
|
|
float2 texcoord : TEXCOORD0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct VertexOutput {
|
|
float4 positionCS : SV_POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
|
|
VertexOutput DepthOnlyVertex(VertexInput input)
|
|
{
|
|
VertexOutput output = (VertexOutput)0;
|
|
UNITY_SETUP_INSTANCE_ID(input);
|
|
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
|
|
|
#if defined(_ALPHATEST_ON)
|
|
output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
|
|
#endif
|
|
|
|
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
|
return output;
|
|
}
|
|
|
|
half4 DepthOnlyFragment(VertexOutput input) : SV_TARGET
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID(input);
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
|
|
|
#if defined(_ALPHATEST_ON)
|
|
half mask = SAMPLE_TEXTURE2D(_MaskMap, sampler_MaskMap, input.uv.xy).a;
|
|
clip (mask - _Cutoff);
|
|
#endif
|
|
|
|
return 0;
|
|
}
|
|
|
|
ENDHLSL
|
|
}
|
|
|
|
|
|
|
|
|
|
// End Passes -----------------------------------------------------
|
|
|
|
}
|
|
FallBack "Hidden/InternalErrorShader"
|
|
//CustomEditor "LuxURPUniversalCustomShaderGUI"
|
|
}
|