49 lines
1.3 KiB
HLSL
49 lines
1.3 KiB
HLSL
#include "bindless_structs.hlsli"
|
|
|
|
struct VS_Input
|
|
{
|
|
uint vertexIndex : SV_VertexID;
|
|
};
|
|
|
|
struct VS_Output
|
|
{
|
|
float4 outPosition : POSITION;
|
|
float4 outColor : COLOR0;
|
|
float2 outUV : TEXCOORD0;
|
|
float outMetal : METAL;
|
|
float4 position : SV_Position;
|
|
};
|
|
|
|
float2 GetUV(uint bufferId, uint vertexIdx)
|
|
{
|
|
if (bufferId == INVALID_HANDLE)
|
|
{
|
|
return 0.0f.xx;
|
|
}
|
|
else
|
|
{
|
|
return uvBuffer[bufferId][vertexIdx];
|
|
}
|
|
}
|
|
|
|
float3 GetPosition(uint bufferId, uint vertexIdx)
|
|
{
|
|
return vertexBuffer[bufferId][vertexIdx].xyz;
|
|
}
|
|
|
|
float4 GetColor(uint bufferId, uint vertexIdx)
|
|
{
|
|
return (bufferId != INVALID_HANDLE) ? colorBuffer[bufferId][vertexIdx] : float4(1.0f, 0.0f, 1.0f, 1.0f);
|
|
}
|
|
|
|
VS_Output main(VS_Input stage_input)
|
|
{
|
|
VS_Output output;
|
|
output.outMetal = materialsBuffer[pcb.materialBufferHandle][pcb.m_MaterialIdx].m_MetalFactor;
|
|
output.outPosition = float4(GetPosition(pcb.vertexBufferHandle, stage_input.vertexIndex), 1.0f);
|
|
output.outUV = GetUV(pcb.uvBufferHandle, stage_input.vertexIndex);
|
|
output.outColor = GetColor(pcb.colorHandle, stage_input.vertexIndex);
|
|
output.position = mul(float4(GetPosition(pcb.vertexBufferHandle, stage_input.vertexIndex), 1.0f), mul(camera.model, mul(camera.view, camera.proj)));
|
|
return output;
|
|
}
|