Formalize builtin shader resource contracts
This commit is contained in:
73
engine/assets/builtin/shaders/depth-only.shader
Normal file
73
engine/assets/builtin/shaders/depth-only.shader
Normal file
@@ -0,0 +1,73 @@
|
||||
Shader "Builtin Depth Only"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_BaseColor ("Base Color", Color) = (1,1,1,1) [Semantic(BaseColor)]
|
||||
_Cutoff ("Alpha Cutoff", Range) = 0.5 [Semantic(AlphaCutoff)]
|
||||
_MainTex ("Base Map", 2D) = "white" [Semantic(BaseColorTexture)]
|
||||
}
|
||||
HLSLINCLUDE
|
||||
cbuffer PerObjectConstants
|
||||
{
|
||||
float4x4 gProjectionMatrix;
|
||||
float4x4 gViewMatrix;
|
||||
float4x4 gModelMatrix;
|
||||
};
|
||||
|
||||
cbuffer MaterialConstants
|
||||
{
|
||||
float4 gBaseColorFactor;
|
||||
float4 gAlphaCutoffParams;
|
||||
};
|
||||
|
||||
Texture2D BaseColorTexture;
|
||||
SamplerState LinearClampSampler;
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PSInput
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
PSInput MainVS(VSInput input)
|
||||
{
|
||||
PSInput output;
|
||||
const float4 positionWS = mul(gModelMatrix, float4(input.position, 1.0f));
|
||||
const float4 positionVS = mul(gViewMatrix, positionWS);
|
||||
output.position = mul(gProjectionMatrix, positionVS);
|
||||
output.texcoord = input.texcoord;
|
||||
return output;
|
||||
}
|
||||
|
||||
float MainPS(PSInput input) : SV_Depth
|
||||
{
|
||||
#ifdef XC_ALPHA_TEST
|
||||
const float4 baseColor =
|
||||
BaseColorTexture.Sample(LinearClampSampler, input.texcoord) * gBaseColorFactor;
|
||||
clip(baseColor.a - gAlphaCutoffParams.x);
|
||||
#endif
|
||||
return input.position.z;
|
||||
}
|
||||
ENDHLSL
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
Name "DepthOnly"
|
||||
Tags { "LightMode" = "DepthOnly" }
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.5
|
||||
#pragma vertex MainVS
|
||||
#pragma fragment MainPS
|
||||
#pragma shader_feature_local _ XC_ALPHA_TEST
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user