62 lines
1.5 KiB
HLSL
62 lines
1.5 KiB
HLSL
|
|
struct VS_Input
|
|
{
|
|
uint VertexIndex : SV_VertexID;
|
|
};
|
|
|
|
struct VS_Out {
|
|
float4 WorldNormal : NORMAL;
|
|
float4 WorldPosition : POSITION;
|
|
float4 Color : COLOR0;
|
|
float2 TexCoord0 : TEXCOORD0;
|
|
};
|
|
|
|
struct CameraData
|
|
{
|
|
float4x4 View; // 64
|
|
float4x4 Projection; // 128
|
|
float4x4 InvView; // 192
|
|
float4x4 InvProjection; // 256
|
|
float4 Position; // 272
|
|
};
|
|
|
|
[[vk::binding(0, 1)]] ConstantBuffer<CameraData> Camera;
|
|
|
|
struct VertexData {
|
|
float4 Normal;
|
|
float2 TexCoord0;
|
|
float2 TexCoord1;
|
|
float4 Color;
|
|
};
|
|
|
|
[[vk::binding(0, 0)]] ByteAddressBuffer GeometryBuffer[];
|
|
|
|
layout(set=1, binding=0) uniform Camera {
|
|
float4x4 View; // 64
|
|
float4x4 Projection; // 128
|
|
float4x4 InvView; // 192
|
|
float4x4 InvProjection; // 256
|
|
float4 Position; // 272
|
|
} Camera;
|
|
|
|
layout(push_constant) uniform Constants {
|
|
mat4 globalTransform;
|
|
uint64 vertexPos;
|
|
VDataRef vertexDat;
|
|
uint64_t materialIdx;
|
|
} pcb;
|
|
|
|
void main() {
|
|
VS_Output Output;
|
|
|
|
float4 GlobalPosition = mul(globalTransform, GeometryBuffer[0].Load<float4>());
|
|
float4 ClipSpace = mul(Camera.View, GlobalPosition);
|
|
|
|
Output.VertexPosition = mul(Camera.Projection, ClipSpace);
|
|
Output.WorldPosition = GlobalPosition;
|
|
Output.UV0 = GetUV(StageInput.VertexIndex);
|
|
Output.VertexColor = GetColor(StageInput.VertexIndex);
|
|
|
|
Output.WorldNormal = mul(GetNormalTransform(PushConstant.NodeIdx), GetNormal(StageInput.VertexIndex));
|
|
return Output;
|
|
} |