power_play/res/sh/common.hlsl
2025-06-23 16:38:55 -05:00

29 lines
672 B
HLSL

#include "sh/sh_common.h"
#define PI 3.14159265359
#define GOLDEN 1.61803398875
#define DECL(t, n) t n : n
#define NURI(i) NonUniformResourceIndex(i)
#if !SH_CPU
# define INLINE /* For intellisense */
#endif
/* Linear color from normalized sRGB */
INLINE float4 linear_from_srgb(float4 srgb)
{
return float4(pow(srgb.rgb, 2.2), srgb.a);
}
/* Linear color from R8G8B8A8 sRGB */
INLINE 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);
}