0.00
60.0 fps
Mixed noises
Mix noises while preserving the histogram.
Log in to post a comment.
#version 300 es
precision highp float;
uniform float iTime;
uniform vec2 iResolution;
uniform float HistogramPreserve; // value=1, min=0, max=1, step=1 (No, Yes)
out vec4 fragColor;
float hash12(vec2 p) {
vec3 p3 = fract(vec3(p.xyx) * .1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}
void main() {
float n0 = hash12(gl_FragCoord.xy);
float n1 = hash12(gl_FragCoord.yx + 0.5);
float f = .5 + .5 * sin(gl_FragCoord.x / iResolution.x * 20. + 2. * iTime);
float h = mix(n0, n1, f);
float g = min(f, 1. - f);
float x = min(h, 1. - h);
float v = (x < g)
? x * x / (2. * g)
: x - 0.5 * g;
float h1 = v / (1. - g);
h1 = (h < 0.5) ? h1 : 1. - h1;
vec3 col = vec3(mix(h, h1, HistogramPreserve));
fragColor = vec4(col, 1.);
}