2025-03-28 15:16:45 +01:00
|
|
|
/* Copyright (c) 2025, Sascha Willems
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2025-03-29 10:31:46 +01:00
|
|
|
Sampler2D samplerColorMap;
|
|
|
|
|
|
2025-03-28 15:16:45 +01:00
|
|
|
struct VSInput
|
|
|
|
|
{
|
2025-03-29 10:31:46 +01:00
|
|
|
float3 Pos;
|
|
|
|
|
float3 Normal;
|
|
|
|
|
float2 UV;
|
|
|
|
|
float3 Color;
|
2025-03-28 15:16:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct MatrixReference {
|
|
|
|
|
float4x4 matrix;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct PushConsts {
|
|
|
|
|
// Pointer to the buffer with the scene's MVP matrix
|
|
|
|
|
ConstBufferPointer<MatrixReference> sceneDataReference;
|
|
|
|
|
// Pointer to the buffer for the data for each model
|
|
|
|
|
ConstBufferPointer<MatrixReference> modelDataReference;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct VSOutput
|
|
|
|
|
{
|
|
|
|
|
float4 Pos : SV_POSITION;
|
2025-03-29 10:31:46 +01:00
|
|
|
float3 Normal;
|
|
|
|
|
float3 Color;
|
|
|
|
|
float2 UV;
|
2025-03-28 15:16:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[shader("vertex")]
|
2025-03-29 10:31:46 +01:00
|
|
|
VSOutput vertexMain(VSInput input, uniform PushConsts pushConstants)
|
2025-03-28 15:16:45 +01:00
|
|
|
{
|
|
|
|
|
MatrixReference sceneData = pushConstants.sceneDataReference.get();
|
|
|
|
|
MatrixReference modelData = pushConstants.modelDataReference.get();
|
|
|
|
|
|
|
|
|
|
VSOutput output;
|
|
|
|
|
output.Normal = input.Normal;
|
|
|
|
|
output.Color = input.Color;
|
|
|
|
|
output.UV = input.UV;
|
|
|
|
|
output.Pos = mul(sceneData.matrix, mul(modelData.matrix, float4(input.Pos.xyz, 1.0)));
|
|
|
|
|
return output;
|
2025-03-29 10:31:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[shader("fragment")]
|
|
|
|
|
float4 fragmentMain(VSOutput input)
|
|
|
|
|
{
|
|
|
|
|
return samplerColorMap.Sample(input.UV) * float4(input.Color, 1.0);
|
2025-03-28 15:16:45 +01:00
|
|
|
}
|