51 lines
1.3 KiB
Plaintext
51 lines
1.3 KiB
Plaintext
Shader "Builtin Object Id"
|
|
{
|
|
SubShader
|
|
{
|
|
Pass
|
|
{
|
|
Name "ObjectId"
|
|
Tags { "LightMode" = "ObjectId" }
|
|
Cull Back
|
|
ZWrite On
|
|
ZTest LEqual
|
|
HLSLPROGRAM
|
|
#pragma target 4.5
|
|
#pragma vertex MainVS
|
|
#pragma fragment MainPS
|
|
cbuffer PerObjectConstants
|
|
{
|
|
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;
|
|
}
|
|
ENDHLSL
|
|
}
|
|
}
|
|
}
|