30 lines
655 B
HLSL
30 lines
655 B
HLSL
#define DECL(t, n) t n : n
|
|
#define DESV(t, n, s) t n : s
|
|
|
|
struct xform {
|
|
float2 bx;
|
|
float2 by;
|
|
float2 og;
|
|
};
|
|
|
|
/* 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);
|
|
}
|
|
|
|
float2 xform_mul(struct xform xf, float2 v)
|
|
{
|
|
return xf.bx * v.x + xf.by * v.y + xf.og;
|
|
} |