rendering: migrate object id shader to unity-style single source
This commit is contained in:
@@ -6,16 +6,44 @@ Shader "Builtin Object Id"
|
||||
{
|
||||
Name "ObjectId"
|
||||
Tags { "LightMode" = "ObjectId" }
|
||||
Resources
|
||||
{
|
||||
PerObjectConstants (ConstantBuffer, 0, 0) [Semantic(PerObject)]
|
||||
}
|
||||
Cull Back
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
HLSLPROGRAM
|
||||
#pragma target 4.5
|
||||
#pragma vertex MainVS
|
||||
#pragma fragment MainPS
|
||||
#pragma backend D3D12 HLSL "object-id.vs.hlsl" "object-id.ps.hlsl" vs_5_0 ps_5_0
|
||||
#pragma backend OpenGL GLSL "object-id.vert.glsl" "object-id.frag.glsl"
|
||||
#pragma backend Vulkan GLSL "object-id.vert.vk.glsl" "object-id.frag.vk.glsl"
|
||||
cbuffer PerObjectConstants : register(b0)
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user