A game about forced loneliness, made by TACStudios
1void Hash_Tchou_2_1_uint(uint2 v, out uint o)
2{
3 // ~6 alu (2 mul)
4 v.y ^= 1103515245U;
5 v.x += v.y;
6 v.x *= v.y;
7 v.x ^= v.x >> 5u;
8 v.x *= 0x27d4eb2du;
9 o = v.x;
10}
11
12void Hash_Tchou_2_1_float(float2 i, out float o)
13{
14 uint r;
15 uint2 v = (uint2) (int2) round(i);
16 Hash_Tchou_2_1_uint(v, r);
17 o = (r >> 8) * (1.0 / float(0x00ffffff));
18}
19
20void Hash_Tchou_2_1_half(half2 i, out half o)
21{
22 uint r;
23 uint2 v = (uint2) (int2) round(i);
24 Hash_Tchou_2_1_uint(v, r);
25 o = (r >> 8) * (1.0 / float(0x00ffffff));
26}
27
28void Hash_Tchou_2_3_uint(uint2 q, out uint3 o)
29{
30 // ~10 alu (2 mul)
31 uint3 v;
32 v.xy = q;
33 v.y ^= 1103515245U;
34 v.x += v.y;
35 v.x *= v.y;
36 v.x ^= v.x >> 5u;
37 v.x *= 0x27d4eb2du;
38 v.y ^= (v.x << 3u);
39 v.z = v.x ^ (v.y << 5u);
40 o = v;
41}
42
43void Hash_Tchou_2_3_float(float2 i, out float3 o)
44{
45 uint3 r;
46 uint2 v = (uint2) (int2) round(i);
47 Hash_Tchou_2_3_uint(v, r);
48 o = (r >> 8) * (1.0 / float(0x00ffffff));
49}
50
51void Hash_Tchou_2_3_half(half2 i, out half3 o)
52{
53 uint3 r;
54 uint2 v = (uint2) (int2) round(i);
55 Hash_Tchou_2_3_uint(v, r);
56 o = (r >> 8) * (1.0 / float(0x00ffffff));
57}
58
59void Hash_Tchou_2_2_uint(uint2 v, out uint2 o)
60{
61 // ~8 alu (2 mul)
62 v.y ^= 1103515245U;
63 v.x += v.y;
64 v.x *= v.y;
65 v.x ^= v.x >> 5u;
66 v.x *= 0x27d4eb2du;
67 v.y ^= (v.x << 3u);
68 o = v;
69}
70
71void Hash_Tchou_2_2_float(float2 i, out float2 o)
72{
73 uint2 r;
74 uint2 v = (uint2) (int2) round(i);
75 Hash_Tchou_2_2_uint(v, r);
76 o = (r >> 8) * (1.0 / float(0x00ffffff));
77}
78
79void Hash_Tchou_2_2_half(half2 i, out half2 o)
80{
81 uint2 r;
82 uint2 v = (uint2) (int2) round(i);
83 Hash_Tchou_2_2_uint(v, r);
84 o = (r >> 8) * (1.0 / float(0x00ffffff));
85}
86
87void Hash_Tchou_3_1_uint(uint3 v, out uint o)
88{
89 // ~15 alu (3 mul)
90 v.x ^= 1103515245U;
91 v.y ^= v.x + v.z;
92 v.y = v.y * 134775813;
93 v.z += v.x ^ v.y;
94 v.y += v.x ^ v.z;
95 v.x += v.y * v.z;
96 v.x = v.x * 0x27d4eb2du;
97 o = v.x;
98}
99
100void Hash_Tchou_3_1_float(float3 i, out float o)
101{
102 uint r;
103 uint3 v = (uint3) (int3) round(i);
104 Hash_Tchou_3_1_uint(v, r);
105 o = (r >> 8) * (1.0 / float(0x00ffffff));
106}
107
108void Hash_Tchou_3_1_half(half3 i, out half o)
109{
110 uint r;
111 uint3 v = (uint3) (int3) round(i);
112 Hash_Tchou_3_1_uint(v, r);
113 o = (r >> 8) * (1.0 / float(0x00ffffff));
114}
115
116void Hash_Tchou_3_3_uint(uint3 v, out uint3 o)
117{
118 // ~15 alu (3 mul)
119 v.x ^= 1103515245U;
120 v.y ^= v.x + v.z;
121 v.y = v.y * 134775813;
122 v.z += v.x ^ v.y;
123 v.y += v.x ^ v.z;
124 v.x += v.y * v.z;
125 v.x = v.x * 0x27d4eb2du;
126 v.z ^= v.x << 3;
127 v.y += v.z << 3;
128 o = v;
129}
130
131void Hash_Tchou_3_3_float(float3 i, out float3 o)
132{
133 uint3 r, v = (uint3) (int3) round(i);
134 Hash_Tchou_3_3_uint(v, r);
135 o = (r >> 8) * (1.0 / float(0x00ffffff));
136}
137
138void Hash_Tchou_3_3_half(half3 i, out half3 o)
139{
140 uint3 r, v = (uint3) (int3) round(i);
141 Hash_Tchou_3_3_uint(v, r);
142 o = (r >> 8) * (1.0 / float(0x00ffffff));
143}
144
145void Hash_LegacySine_2_1_float(float2 i, out float o)
146{
147 float angle = dot(i, float2(12.9898, 78.233));
148#if defined(SHADER_API_MOBILE) && (defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || defined(SHADER_API_WEBGPU))
149 // 'sin()' has bad precision on Mali GPUs for inputs > 10000
150 angle = fmod(angle, TWO_PI); // Avoid large inputs to sin()
151#endif
152 o = frac(sin(angle)*43758.5453);
153}
154
155void Hash_LegacySine_2_1_half(half2 i, out half o)
156{
157 half angle = dot(i, half2(12.9898, 78.233));
158#if defined(SHADER_API_MOBILE) && (defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || defined(SHADER_API_WEBGPU))
159 // 'sin()' has bad precision on Mali GPUs for inputs > 10000
160 angle = fmod(angle, TWO_PI); // Avoid large inputs to sin()
161#endif
162 o = frac(sin(angle)*43758.5453);
163}
164
165void Hash_BetterSine_2_1_float(float2 i, out float o)
166{
167 float angle = dot(i, float2(12.9898, 78.233) / 1000.0f);
168#if defined(SHADER_API_MOBILE) && (defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || defined(SHADER_API_WEBGPU))
169 // 'sin()' has bad precision on Mali GPUs for inputs > 10000
170 angle = fmod(angle, TWO_PI); // Avoid large inputs to sin()
171#endif
172 o = frac(sin(angle)*43758.5453);
173}
174
175void Hash_BetterSine_2_1_half(half2 i, out half o)
176{
177 float angle = dot(i, half2(12.9898, 78.233) / 1000.0f);
178#if defined(SHADER_API_MOBILE) && (defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || defined(SHADER_API_WEBGPU))
179 // 'sin()' has bad precision on Mali GPUs for inputs > 10000
180 angle = fmod(angle, TWO_PI); // Avoid large inputs to sin()
181#endif
182 o = frac(sin(angle)*43758.5453);
183}
184
185void Hash_LegacySine_2_2_float(float2 i, out float2 o)
186{
187 float2x2 m = float2x2(15.27, 47.63, 99.41, 89.98);
188 float2 angles = mul(i, m);
189#if defined(SHADER_API_MOBILE) && (defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || defined(SHADER_API_WEBGPU))
190 // 'sin()' has bad precision on Mali GPUs for inputs > 10000
191 angles = fmod(angles, TWO_PI); // Avoid large inputs to sin()
192#endif
193 o = frac(sin(angles));
194}
195
196void Hash_LegacySine_2_2_half(half2 i, out half2 o)
197{
198 half2x2 m = half2x2(15.27, 47.63, 99.41, 89.98);
199 half2 angles = mul(i, m);
200#if defined(SHADER_API_MOBILE) && (defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || defined(SHADER_API_WEBGPU))
201 // 'sin()' has bad precision on Mali GPUs for inputs > 10000
202 angles = fmod(angles, TWO_PI); // Avoid large inputs to sin()
203#endif
204 o = frac(sin(angles));
205}
206
207void Hash_LegacyMod_2_1_float(float2 i, out float o)
208{
209 // Permutation and hashing used in webgl-nosie goo.gl/pX7HtC
210 i = i % 289;
211 // need full precision, otherwise half overflows when p > 1
212 float x = float(34 * i.x + 1) * i.x % 289 + i.y;
213 x = (34 * x + 1) * x % 289;
214 x = frac(x / 41) * 2 - 1;
215 o = x;
216}
217
218void Hash_LegacyMod_2_1_half(half2 i, out half o)
219{
220 // Permutation and hashing used in webgl-nosie goo.gl/pX7HtC
221 i = i % 289;
222 // need full precision, otherwise half overflows when p > 1
223 float x = float(34 * i.x + 1) * i.x % 289 + i.y;
224 x = (34 * x + 1) * x % 289;
225 x = frac(x / 41) * 2 - 1;
226 o = x;
227}