feat(default): faster rand in default project

This commit is contained in:
2026-08-30 11:30:22 +02:00
parent 2a7d1f6df4
commit 7a2bafc8de
+11 -5
View File
@@ -1,14 +1,20 @@
#ifndef INC_RAND #ifndef INC_RAND
#define INC_RAND #define INC_RAND
// https://thebookofshaders.com/10/
// https://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/
float rand(float seed){ float rand(float seed){
float v = pow(abs(seed), .8571429); // 6. / 7. const float c = 43758.5453;
v *= sin(v) + 1.; return fract(sin(seed) * c);
return fract(v);
} }
float rand(vec2 n){ float rand(vec2 co)
return rand(n.x * 1234. + n.y * 9876.); {
const float a = 12.9898;
const float b = 78.233;
float dt= dot(co.xy ,vec2(a,b));
return rand(dt);
} }
#endif #endif