power_play/res/sh/common.hlsl
2025-06-25 16:17:14 -05:00

29 lines
679 B
HLSL

#include "sh/sh_common.h"
#define PI 3.14159265359
#define GOLDEN 1.61803398875
#define DECLS(t, n) t n : n
#define NURID(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(abs(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);
}