summaryrefslogtreecommitdiffstats
path: root/math.cginc
diff options
context:
space:
mode:
Diffstat (limited to 'math.cginc')
-rwxr-xr-xmath.cginc18
1 files changed, 11 insertions, 7 deletions
diff --git a/math.cginc b/math.cginc
index 6bca086..55e1e35 100755
--- a/math.cginc
+++ b/math.cginc
@@ -1,6 +1,8 @@
#ifndef __MATH_INC
#define __MATH_INC
+#include "hashwithoutsine.cginc"
+
#define PI 3.14159265358979323846264f
#define TAU (2.0f * PI)
#define HALF_PI (PI * 0.5f)
@@ -115,13 +117,6 @@ float4 alpha_blend(float4 front, float4 back) {
return float4(front.rgb * front.a + back.rgb * (1 - front.a), front.a + back.a * (1 - front.a));
}
-// 3 in 3 out hash. Based on the "hashwithoutsine" family.
-float3 hash33_fast(float3 p) {
- p = frac(p * float3(0.1031, 0.1030, 0.0973));
- p += dot(p, p.yxz + 33.33);
- return frac((p.xxy + p.yxx) * p.zyx);
-}
-
// O'Neill-style PCG 32-bit output permutation (RXS-M-XS).
uint pcg32(uint input) {
uint state = input * 747796405u + 2891336453u;
@@ -263,4 +258,13 @@ float3 srgb_to_linear(float3 srgb_color) {
return lerp(lo, hi, step(0.04045f, srgb_color));
}
+float2x2 inverse(float2x2 m) {
+ float det = (m[0][0] * m[1][1]) - (m[0][1] * m[1][0]);
+
+ return float2x2(
+ m[1][1], -m[0][1],
+ -m[1][0], m[0][0]
+ ) / det;
+}
+
#endif // __MATH_INC