59 lines
2.0 KiB
Plaintext
59 lines
2.0 KiB
Plaintext
// =====================================================
|
|
// UI Shader pour CosmicCore
|
|
// Set 0 : Transform (UBO - par objet)
|
|
// Set 1 : Material (UBO + Texture)
|
|
// Set 2 : Projection (UBO - global)
|
|
// =====================================================
|
|
|
|
// ─── Inputs ────────────────────────────────────────────
|
|
struct VSInput {
|
|
[[vk::location(0)]] float2 inPosition;
|
|
[[vk::location(1)]] float2 inUV;
|
|
[[vk::location(2)]] float4 inColor;
|
|
};
|
|
|
|
// ─── Outputs ───────────────────────────────────────────
|
|
struct VSOutput {
|
|
float4 pos : SV_Position;
|
|
float2 uv : TEXCOORD0;
|
|
float4 color : COLOR;
|
|
};
|
|
|
|
// ─── Set 0 : Transform (UBO par objet) ─────────────────
|
|
struct TransformUBO {
|
|
float4x4 model;
|
|
float2 size;
|
|
float zOrder;
|
|
float padding;
|
|
};
|
|
|
|
[[vk::binding(0, 0)]] ConstantBuffer<TransformUBO> transform;
|
|
|
|
[[vk::binding(1, 1)]] Sampler2D uiTexture;
|
|
|
|
// ─── Set 2 : Projection (UBO global) ──────────────────
|
|
[[vk::binding(0, 2)]] ConstantBuffer<float4x4> projection;
|
|
|
|
// ─── Vertex Shader ──────────────────────────────────────
|
|
[shader("vertex")]
|
|
VSOutput vertMain(VSInput input) {
|
|
VSOutput output;
|
|
|
|
// Transforme local vers monde
|
|
float4 worldPos = mul(transform.model, float4(input.inPosition, 0.0, 1.0));
|
|
|
|
// Applique la projection
|
|
output.pos = mul(projection, worldPos);
|
|
|
|
output.uv = input.inUV;
|
|
output.color = input.inColor;
|
|
|
|
return output;
|
|
}
|
|
|
|
// ─── Fragment Shader ────────────────────────────────────
|
|
[shader("fragment")]
|
|
float4 fragMain(VSOutput vertIn) : SV_Target {
|
|
float4 texColor = uiTexture.Sample(vertIn.uv);
|
|
return vertIn.color * texColor;
|
|
} |