power_play/res/sh/common.hlsl
2025-07-18 12:04:06 -05:00

35 lines
780 B
HLSL

#include "sh/sh_common.h"
#define TAU 6.28318530718
#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
INLINE float4 float4_norm_from_uint(uint v)
{
float4 res;
res.r = ((v >> 0) & 0xFF) / 255.0;
res.g = ((v >> 8) & 0xFF) / 255.0;
res.b = ((v >> 16) & 0xFF) / 255.0;
res.a = ((v >> 24) & 0xFF) / 255.0;
return res;
}
/* 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)
{
return linear_from_srgb(float4_norm_from_uint(srgb32));
}