2026-04-04 16:42:31 +08:00
|
|
|
Shader "Builtin Object Id"
|
2026-04-02 23:15:19 +08:00
|
|
|
{
|
2026-04-04 16:42:31 +08:00
|
|
|
SubShader
|
2026-04-02 23:15:19 +08:00
|
|
|
{
|
2026-04-04 16:42:31 +08:00
|
|
|
Pass
|
2026-04-03 17:05:38 +08:00
|
|
|
{
|
2026-04-04 16:42:31 +08:00
|
|
|
Name "ObjectId"
|
|
|
|
|
Tags { "LightMode" = "ObjectId" }
|
2026-04-07 00:38:00 +08:00
|
|
|
Cull Back
|
|
|
|
|
ZWrite On
|
|
|
|
|
ZTest LEqual
|
2026-04-04 16:42:31 +08:00
|
|
|
HLSLPROGRAM
|
2026-04-07 00:38:00 +08:00
|
|
|
#pragma target 4.5
|
2026-04-04 16:42:31 +08:00
|
|
|
#pragma vertex MainVS
|
|
|
|
|
#pragma fragment MainPS
|
2026-04-07 10:34:20 +08:00
|
|
|
cbuffer PerObjectConstants
|
2026-04-07 00:38:00 +08:00
|
|
|
{
|
|
|
|
|
float4x4 gProjectionMatrix;
|
|
|
|
|
float4x4 gViewMatrix;
|
|
|
|
|
float4x4 gModelMatrix;
|
|
|
|
|
float4 gObjectIdColor;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct VSInput
|
|
|
|
|
{
|
|
|
|
|
float3 position : POSITION;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct PSInput
|
|
|
|
|
{
|
|
|
|
|
float4 position : SV_POSITION;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PSInput MainVS(VSInput input)
|
|
|
|
|
{
|
|
|
|
|
PSInput output;
|
|
|
|
|
const float4 positionWS = mul(gModelMatrix, float4(input.position, 1.0));
|
|
|
|
|
const float4 positionVS = mul(gViewMatrix, positionWS);
|
|
|
|
|
output.position = mul(gProjectionMatrix, positionVS);
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float4 MainPS(PSInput input) : SV_TARGET
|
|
|
|
|
{
|
|
|
|
|
return gObjectIdColor;
|
|
|
|
|
}
|
2026-04-04 16:42:31 +08:00
|
|
|
ENDHLSL
|
2026-04-03 17:05:38 +08:00
|
|
|
}
|
2026-04-02 23:15:19 +08:00
|
|
|
}
|
|
|
|
|
}
|