block improvements, autolock improvements and auto off, block button auto on/off, recoil anim improvement
This commit is contained in:
@@ -1,20 +1,79 @@
|
||||
Shader "Unlit/DepthPrepassTransparent"
|
||||
{
|
||||
|
||||
Properties
|
||||
{
|
||||
// This property is necessary to receive the texture from the main material
|
||||
_MainTex("Texture", 2D) = "white" {}
|
||||
// This property is necessary to receive the alpha cutoff value from the main material
|
||||
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
|
||||
Tags {
|
||||
"Queue" = "Transparent"
|
||||
"RenderType" = "Transparent"
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
}
|
||||
|
||||
// This pass is for the depth pre-pass.
|
||||
// It writes depth for transparent objects that need it.
|
||||
Tags { "RenderType" = "TransparentCutout" "RenderPipeline" = "UniversalPipeline" }
|
||||
|
||||
Pass
|
||||
{
|
||||
// Use the "DepthOnly" LightMode for URP to identify this as a depth pass.
|
||||
Name "DepthOnly"
|
||||
Tags { "LightMode" = "DepthOnly" }
|
||||
|
||||
// Write to the depth buffer
|
||||
ZWrite On
|
||||
// Do not write to any color channels
|
||||
ColorMask 0
|
||||
}
|
||||
// Standard back-face culling
|
||||
Cull Back
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
// Includes for URP core functionality
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
// Match the properties block
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
half _Cutoff;
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
// Standard vertex transformation
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
output.uv = input.uv;
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(Varyings input) : SV_TARGET
|
||||
{
|
||||
// Sample the texture to get the alpha value
|
||||
half alpha = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv).a;
|
||||
|
||||
// Perform alpha clipping. Discard the fragment if its alpha is below the cutoff.
|
||||
// This ensures the depth shape matches the visible shape.
|
||||
clip(alpha - _Cutoff);
|
||||
|
||||
// We don't need to return a color as ColorMask is 0,
|
||||
// but the function must return something.
|
||||
return 0;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user