Replace separate slang files per stage with single slang files containing multiple stages
This commit is contained in:
parent
cf3700cb2f
commit
c4556374c3
8 changed files with 44 additions and 87 deletions
|
|
@ -1,20 +0,0 @@
|
|||
/* Copyright (c) 2025, Sascha Willems
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
[[vk::binding(0, 0)]]
|
||||
Sampler2D fontTexture;
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
[[vk::location(0)]]float2 UV : TEXCOORD0;
|
||||
[[vk::location(1)]]float4 Color : COLOR0;
|
||||
};
|
||||
|
||||
[shader("fragment")]
|
||||
float4 main(VSOutput input) : SV_TARGET
|
||||
{
|
||||
return input.Color * fontTexture.Sample(input.UV);
|
||||
}
|
||||
|
|
@ -4,18 +4,20 @@
|
|||
*
|
||||
*/
|
||||
|
||||
Sampler2D fontTexture;
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
[[vk::location(0)]]float2 Pos : POSITION0;
|
||||
[[vk::location(1)]]float2 UV : TEXCOORD0;
|
||||
[[vk::location(2)]]float4 Color : COLOR0;
|
||||
float2 Pos : POSITION0;
|
||||
float2 UV;
|
||||
float4 Color;
|
||||
};
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]]float2 UV : TEXCOORD0;
|
||||
[[vk::location(1)]]float4 Color : COLOR0;
|
||||
float2 UV;
|
||||
float4 Color;
|
||||
};
|
||||
|
||||
struct PushConstants
|
||||
|
|
@ -24,11 +26,8 @@ struct PushConstants
|
|||
float2 translate;
|
||||
};
|
||||
|
||||
[[vk::push_constant]]
|
||||
PushConstants pushConstants;
|
||||
|
||||
[shader("vertex")]
|
||||
VSOutput main(VSInput input)
|
||||
VSOutput vertexMain(VSInput input, uniform PushConstants pushConstants)
|
||||
{
|
||||
VSOutput output;
|
||||
output.Pos = float4(input.Pos * pushConstants.scale + pushConstants.translate, 0.0, 1.0);
|
||||
|
|
@ -36,3 +35,9 @@ VSOutput main(VSInput input)
|
|||
output.Color = input.Color;
|
||||
return output;
|
||||
}
|
||||
|
||||
[shader("fragment")]
|
||||
float4 fragmentMain(VSOutput input)
|
||||
{
|
||||
return input.Color * fontTexture.Sample(input.UV);
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
/* Copyright (c) 2025, Sascha Willems
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
[[vk::binding(0, 0)]]
|
||||
Sampler2D samplerColorMap;
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
[[vk::location(1)]] float3 Color;
|
||||
[[vk::location(2)]] float2 UV;
|
||||
};
|
||||
|
||||
[shader("fragment")]
|
||||
float4 main(VSInput input)
|
||||
{
|
||||
return samplerColorMap.Sample(input.UV) * float4(input.Color, 1.0);
|
||||
}
|
||||
|
|
@ -4,12 +4,14 @@
|
|||
*
|
||||
*/
|
||||
|
||||
Sampler2D samplerColorMap;
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
[[vk::location(0)]] float3 Pos;
|
||||
[[vk::location(1)]] float3 Normal;
|
||||
[[vk::location(2)]] float2 UV;
|
||||
[[vk::location(3)]] float3 Color;
|
||||
float3 Pos;
|
||||
float3 Normal;
|
||||
float2 UV;
|
||||
float3 Color;
|
||||
};
|
||||
|
||||
struct MatrixReference {
|
||||
|
|
@ -22,18 +24,17 @@ struct PushConsts {
|
|||
// Pointer to the buffer for the data for each model
|
||||
ConstBufferPointer<MatrixReference> modelDataReference;
|
||||
};
|
||||
[[vk::push_constant]] PushConsts pushConstants;
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] float3 Normal;
|
||||
[[vk::location(1)]] float3 Color;
|
||||
[[vk::location(2)]] float2 UV;
|
||||
float3 Normal;
|
||||
float3 Color;
|
||||
float2 UV;
|
||||
};
|
||||
|
||||
[shader("vertex")]
|
||||
VSOutput main(VSInput input)
|
||||
VSOutput vertexMain(VSInput input, uniform PushConsts pushConstants)
|
||||
{
|
||||
MatrixReference sceneData = pushConstants.sceneDataReference.get();
|
||||
MatrixReference modelData = pushConstants.modelDataReference.get();
|
||||
|
|
@ -45,3 +46,9 @@ VSOutput main(VSInput input)
|
|||
output.Pos = mul(sceneData.matrix, mul(modelData.matrix, float4(input.Pos.xyz, 1.0)));
|
||||
return output;
|
||||
}
|
||||
|
||||
[shader("fragment")]
|
||||
float4 fragmentMain(VSOutput input)
|
||||
{
|
||||
return samplerColorMap.Sample(input.UV) * float4(input.Color, 1.0);
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
/* Copyright (c) 2025, Sascha Willems
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float3 Color;
|
||||
};
|
||||
|
||||
[shader("fragment")]
|
||||
float4 main(VSOutput input) : SV_TARGET
|
||||
{
|
||||
return float4(input.Color, 1.0);
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ struct VSOutput
|
|||
|
||||
// Uniform entry-point parameters are automatically bound to push constants by slang
|
||||
[shader("vertex")]
|
||||
VSOutput main(VSInput input, uniform float4 pushColor, uniform float4 pushPosition)
|
||||
VSOutput vertexMain(VSInput input, uniform float4 pushColor, uniform float4 pushPosition)
|
||||
{
|
||||
VSOutput output;
|
||||
output.Color = input.Color * pushColor.rgb;
|
||||
|
|
@ -36,3 +36,9 @@ VSOutput main(VSInput input, uniform float4 pushColor, uniform float4 pushPositi
|
|||
output.Pos = mul(ubo.projection, mul(ubo.view, float4(worldPos.xyz, 1.0)));
|
||||
return output;
|
||||
}
|
||||
|
||||
[shader("fragment")]
|
||||
float4 fragmentMain(VSOutput input) : SV_TARGET
|
||||
{
|
||||
return float4(input.Color, 1.0);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/* Copyright (c) 2025, Sascha Willems
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
[shader("fragment")]
|
||||
float4 main([[vk::location(0)]] float3 Color)
|
||||
{
|
||||
return float4(Color, 1.0);
|
||||
}
|
||||
|
|
@ -26,10 +26,16 @@ struct VSOutput
|
|||
};
|
||||
|
||||
[shader("vertex")]
|
||||
VSOutput main(VSInput input)
|
||||
VSOutput vertexMain(VSInput input)
|
||||
{
|
||||
VSOutput output;
|
||||
output.Color = input.Color;
|
||||
output.Pos = mul(ubo.projectionMatrix, mul(ubo.viewMatrix, mul(ubo.modelMatrix, float4(input.Pos.xyz, 1.0))));
|
||||
return output;
|
||||
}
|
||||
|
||||
[shader("fragment")]
|
||||
float4 fragmentMain(VSOutput input)
|
||||
{
|
||||
return float4(input.Color, 1.0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue