Fish in the pool

Fish in the pool
Published on Jan 22, 2020 by Jiaolyulu

Like fish in the pool swimming around. Don’t disturb this river of spring’s aroma.
This is using shadertoy especially the FBM. If you are interested in fbm, there is more introduction in the following link.

To see the code in shadertoy:

#define S(a,b,t) smoothstep(a,b,t)

float N21 (vec2 p){
	float d = fract(sin(p.x*110.+(8.21-p.y)*331.)*1218.);
    return d;

float Noise2D(vec2 uv){
    vec2 st = fract(uv);
    vec2 id = floor(uv);
    st = st*st*(3.0-2.0*st);
    float c=mix(mix(N21(id),N21(id+vec2(1.0,0.0)),st.x),mix(N21(id+vec2(0.0,1.0)),N21(id+vec2(1.0,1.0)),st.x),st.y);
	return c;

float fbm (vec2 uv){
    float c=0.;
    return c/(1.-1./16.);

vec3 fbm3(vec2 uv){
    vec3 color;
	float f1 = fbm(uv);
    color= mix(vec3(0.0,0.2,0.3),vec3(0.5,0.1,0.1),2.5*f1);
    float f2 = fbm(2.4*f1+uv+0.15*sin(iTime)*vec2(7.0,-8.0));
    color= mix(color,vec3(0.6,0.5,0.1),1.5*f2);
    float f3 = fbm(3.5*f2+uv-0.15*cos(1.5*iTime)*vec2(4.0,3.0));
    color= mix(color,vec3(0.1,0.4,0.4),f3);
    color= mix(color,vec3(0.4,0.5,0.1),S(0.7,0.72,f2));
    color= mix(color,vec3(0.1,0.5,0.1),S(0.78,0.8,f2));
    color= mix(color,vec3(0.55,0.55,0.35),S(0.88,0.89,f2));
    color= mix(color,vec3(0.55,0.55,0.35),S(0.88,0.88,f3));
    return color;


void mainImage( out vec4 fragColor, in vec2 fragCoord )
    // Normalized pixel coordinates (from 0 to 1)
    vec2 uv = fragCoord/iResolution.xy;
	vec2 mouse = iMouse.xy/iResolution.xy;
    // Time varying pixel color
    vec3 c = fbm3(2.0*(length(uv-mouse)+0.7)*vec2(5.0,5.0)*uv+sin(0.3*iTime)*0.5);
    vec3 col = c;

    // Output to screen
    fragColor = vec4(col,1.0);