#include "mirage_util.slang"

cbuffer ParamBuffer
{
    matrix transform;
};

SamplerState textureSampler;
Texture2D texture;

struct PSInput {
    float4 position : SV_POSITION; 
    float2 uv : TEXCOORD0;
    float4 color : COLOR;
};

[shader("vertex")]
PSInput vertex_main(VSInput input)
{
    PSInput output;

    // 并通过常量缓冲区或结构化缓冲区传递
    output.position = mul(float4(input.position, 0.0, 1.0), transform);
    output.uv = input.uv;
    output.color = input.color;

    return output;
}

[shader("pixel")]
float4 pixel_main(PSInput input) : SV_Target
{
    float4 color = texture.Sample(textureSampler, input.uv);
    float4 final_color = input.color;
    final_color.a *= color.r;
    return final_color;
}
