52 lines
1.2 KiB
HLSL
52 lines
1.2 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;
|
|
float4 position : SV_Position;
|
|
};
|
|
|
|
float2 GetUV(uint vertexIdx)
|
|
{
|
|
uint bufferId = pcb.vertexDataHandle;
|
|
return vertexDataBuffer[bufferId][vertexIdx].m_TexCoord0.xy;
|
|
}
|
|
|
|
float4 GetPosition(uint vertexIdx)
|
|
{
|
|
uint bufferId = pcb.vertexBufferHandle;
|
|
return float4(vertexBuffer[bufferId][vertexIdx].xyz, 1.0f);
|
|
}
|
|
|
|
float4 GetColor(uint vertexIdx)
|
|
{
|
|
uint bufferId = pcb.vertexDataHandle;
|
|
return vertexDataBuffer[bufferId][vertexIdx].m_Color0;
|
|
}
|
|
|
|
float4x4 GetModel(uint index)
|
|
{
|
|
uint bufferId = pcb.nodeBufferHandle;
|
|
return nodeBuffer[bufferId][index].transform;
|
|
}
|
|
|
|
VS_Output main(VS_Input stage_input)
|
|
{
|
|
VS_Output output;
|
|
output.outPosition = GetPosition(stage_input.vertexIndex);
|
|
output.outUV = GetUV(stage_input.vertexIndex);
|
|
output.outColor = GetColor(stage_input.vertexIndex);
|
|
|
|
float4 globalPosition = mul(GetModel(pcb.m_NodeIdx), GetPosition(stage_input.vertexIndex));
|
|
float4 clipSpace = mul(camera.view, globalPosition);
|
|
output.position = mul(camera.proj, clipSpace);
|
|
return output;
|
|
}
|