power_play/res/shaders/common.hlsl
2025-05-28 05:27:56 -05:00

20 lines
497 B
HLSL

#define DECL(t, n) t n : n
#define DESV(t, n, s) t n : s
/* Linear color from normalized sRGB */
float4 linear_from_srgb(float4 srgb)
{
return float4(pow(srgb.rgb, 2.2), srgb.a);
}
/* Linear color from R8G8B8A8 sRGB */
float4 linear_from_srgb32(uint srgb32)
{
float4 res;
res.r = ((srgb32 >> 0) & 0xFF) / 255.0;
res.g = ((srgb32 >> 8) & 0xFF) / 255.0;
res.b = ((srgb32 >> 16) & 0xFF) / 255.0;
res.a = ((srgb32 >> 24) & 0xFF) / 255.0;
return linear_from_srgb(res);
}