-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVertexShader.hlsl
35 lines (29 loc) · 1002 Bytes
/
VertexShader.hlsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
struct VertexOutput {
float4 position : SV_POSITION;
float3 vertPos: VERT_POS;
};
struct CameraConstants {
matrix projMatrix;
matrix cameraMatrix;
};
struct PerFrameConstants {
matrix modelMatrix;
float2 cameraDimensions;
uint frontBufferIndex;
uint backBufferIndex;
uint cubeBufferIndex;
uint volumeDataBufferIndex;
};
ConstantBuffer<CameraConstants> CameraConstantBuffer : register(b0, space0);
ConstantBuffer<PerFrameConstants> PerFrameConstantBuffer : register(b0, space1);
VertexOutput VSMain(uint vertexId : SV_VERTEXID)
{
ByteAddressBuffer vertexBuffer = ResourceDescriptorHeap[PerFrameConstantBuffer.cubeBufferIndex];
float3 pos = vertexBuffer.Load<float3>(vertexId * sizeof(float3));
VertexOutput output;
output.position = mul(float4(pos, 1.0f), PerFrameConstantBuffer.modelMatrix);
output.position = mul(output.position, CameraConstantBuffer.cameraMatrix);
output.position = mul(output.position, CameraConstantBuffer.projMatrix);
output.vertPos = pos;
return output;
}