2 Commits
Author SHA1 Message Date
klemek dcd35af4f1 fix(default): small fixes in default project 2026-08-30 11:30:37 +02:00
klemek 7a2bafc8de feat(default): faster rand in default project 2026-08-30 11:30:22 +02:00
4 changed files with 14 additions and 7 deletions
+1 -1
View File
@@ -109,7 +109,7 @@ void main() {
vec4 color = texture(iTex0, invert ? vUV : uv);
color = mix(color, 1. - color, iDemo * write_int(uv * 20., vec2(1.), iFPS, 2));
color = mix(color, 1. - color, iDemo * write_int_left(uv * 20., vec2(1., 1.), iFPS, 3));
color = mix(color, 1. - color, iDemo * write_5(uv * 20., vec2(1., 18.), textDEMO));
if (visible) {
+1
View File
@@ -381,6 +381,7 @@ float write_int_left(vec2 uv, vec2 pos, int value, int magnitude)
int i;
int m = 1;
float d = 0.;
pos.x -= magnitude;
for (i = 0; i < magnitude; i++) {
if (i == 0 || value >= m) {
pos.x += 1.;
+1 -1
View File
@@ -222,7 +222,7 @@ vec4 debug(vec2 vUV)
// show mix
f += char_at(uv2, vec2(1.55, -.6), mix_type ? 0x4B : 0x4D);
f = mix(f, 1 - f, rect(uv2, vec2(.2, -.9 + .9 * mix_value), vec2(.9, .9 * mix_value)));
f = mix(f, 1 - f, rect(uv2, vec2(2., -.9 + .9 * mix_value), vec2(.9, .9 * mix_value)));
// show debug info
float v = 0.;
+11 -5
View File
@@ -1,14 +1,20 @@
#ifndef 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 v = pow(abs(seed), .8571429); // 6. / 7.
v *= sin(v) + 1.;
return fract(v);
const float c = 43758.5453;
return fract(sin(seed) * c);
}
float rand(vec2 n){
return rand(n.x * 1234. + n.y * 9876.);
float rand(vec2 co)
{
const float a = 12.9898;
const float b = 78.233;
float dt= dot(co.xy ,vec2(a,b));
return rand(dt);
}
#endif