#include "RayTypes.h"

StructuredBuffer<PixelIdData> ComputeBuffer : register(t0, space2);

cbuffer UBO : register(b0, space3)
{
    int4 ubo_size : packoffset(c0);
};

struct Input
{
    float2 TexCoord : TEXCOORD0;
    float4 Color : TEXCOORD1;
};

float4 main(Input input) : SV_Target0
{
    int x = (int) (input.TexCoord.x * ubo_size.x);
    int y = (int) ((1.0 - input.TexCoord.y) * ubo_size.y);
    int i = x + y * ubo_size.x;
    float4 result;
    result.xyz = invfakehdr(input.Color.xyz * ComputeBuffer[i].id.xyz);
    return result;
}
