StepNoise
Random Functions
Kamoshika uses this function that looks to generate continious random value.
code:glsl
float stepNoise(float x, float n) {
n = max(n, 5.);
float i = floor(x);
float s = 0.2;
float u = smoothstep(0.5 - s, 0.5 + s, fract(x));
float res = mix(floor(hash(i) * n), floor(hash(i + 1.) * n), u);
res = res / (n - 1.) - 0.5;
return res;
}
// step(uv.y,stepNoise(uv.x*5+fGlobalTime,30.));
https://scrapbox.io/files/675b2aa28615c43f32c7c398.png
code:glsl
float stepNoise(float x, float n) {
const float factor = 0.3;
float i = floor(x);
float f = x - i;
float u = smoothstep(0.5 - factor, 0.5 + factor, f);
float res = mix(floor(hash(i) * n), floor(hash(i + 1.) * n), u);
res /= (n - 1.) * 0.5;
return res - 1.;
}
//step(uv.y,stepNoise2(uv.x*5+fGlobalTime,30.)*.5)
https://scrapbox.io/files/675b2b8cc89590ad6b3ba5cc.png
Modified version, normalized
code:glsl
vec3 stepNoise(float x,float n,float s){
float i = floor(x);
float u = smoothstep(.5-s,.5+s,fract(x));
vec3 r = mix(floor(hash3d(vec3(i,v2Resolution))*n),floor(hash3d(vec3(i+1,v2Resolution))*n),u);
return (r/(n-1)-.5)*2;
}
// Another minimalized version (used at revision 2025)
vec3 setNoise(float x,float n){
float u = smoothstep(.5-s,.5+s,fract(x));
return mix(hash3d(vec3(floor(x),-1U,1)),hash3d(vec3(floor(x+1),-1U,1)),u);
}