2020-09-19 14:36:50 +02:00
|
|
|
import Material;
|
|
|
|
|
import VERTEX_INPUT_IMPORT;
|
|
|
|
|
import MATERIAL_IMPORT;
|
2020-06-02 11:46:18 +02:00
|
|
|
|
|
|
|
|
struct ViewParams
|
|
|
|
|
{
|
|
|
|
|
float4x4 viewMatrix;
|
|
|
|
|
float4x4 projectionMatrix;
|
|
|
|
|
float4 cameraPos_WS;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
layout(set = 0, binding = 0)
|
|
|
|
|
ParameterBlock<ViewParams> gViewParams;
|
|
|
|
|
|
2020-09-19 14:36:50 +02:00
|
|
|
|
|
|
|
|
layout(set = 1)
|
|
|
|
|
type_param TMaterial : IMaterial;
|
|
|
|
|
ParameterBlock<TMaterial> gMaterial;
|
|
|
|
|
|
2020-06-02 11:46:18 +02:00
|
|
|
struct ModelParameter
|
|
|
|
|
{
|
|
|
|
|
float4x4 modelMatrix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[[vk::push_constant]]
|
|
|
|
|
ConstantBuffer<ModelParameter> gModelParams;
|
|
|
|
|
|
2020-09-19 14:36:50 +02:00
|
|
|
struct VertexStageOutput
|
2020-06-02 11:46:18 +02:00
|
|
|
{
|
2020-09-19 14:36:50 +02:00
|
|
|
float4 position : SV_Position;
|
2020-06-02 11:46:18 +02:00
|
|
|
}
|
|
|
|
|
[shader("vertex")]
|
2020-09-19 14:36:50 +02:00
|
|
|
VertexStageOutput vertexMain(PositionOnlyVertexShaderInput input)
|
|
|
|
|
{
|
|
|
|
|
VertexStageOutput output;
|
|
|
|
|
|
|
|
|
|
float3 worldPosition = input.getWorldPosition();
|
|
|
|
|
worldPosition += gMaterial.getWorldOffset();
|
|
|
|
|
float4 clipSpacePosition;
|
|
|
|
|
|
|
|
|
|
float4 viewSpacePosition = mul(gViewParams.viewMatrix, float4(worldPosition, 1));
|
|
|
|
|
clipSpacePosition = mul(gViewParams.projectionMatrix, viewSpacePosition);
|
|
|
|
|
output.position = clipSpacePosition;
|
|
|
|
|
return output;
|
2020-06-02 11:46:18 +02:00
|
|
|
}
|