Coral sea

Coral sea
Published on Jan 22, 2020 by Jiaolyulu



Here is a kind of coral sea effect I made with shadertoy. It is all written in shader.

I learned from the mysterious mountain made by Dave Hoskins.

I learned about shadertoy from the youtube serial contributed by The Art of Code.

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    // Normalized pixel coordinates (from 0 to 1)
    vec2 uv = fragCoord/iResolution.xy;
	uv-=0.5;
    float t = 0.5*iTime;
    uv.x *= iResolution.x/iResolution.y;
    // Time varying pixel color
    vec4 c,col;
    col = vec4 (0.);
    uv.y-=0.2;
    float m = 0.;
    float ny=uv.y;
    for (float i=1.0; i>=0.0;i-=0.002){
        m-=1.;
    	c = texture(iChannel0, (vec2(uv.x+0.*t,-1.0*i+0.4*t))/vec2(30.0,20.0))*0.5+texture(iChannel0, (vec2(uv.x+0.1*t,-1.0*i+0.4*t))/vec2(20.0,10.0))*0.25+texture(iChannel0, (vec2(uv.x+0.02*t,-1.0*i+0.4*t))/vec2(10.0,5.0))*0.15+texture(iChannel0, (vec2(uv.x+0.08*t,-1.0*i+0.4*t))/vec2(5.0,2.0))*0.1+texture(iChannel0, (vec2(uv.x+0.07*t,-1.0*i+0.4*t))/vec2(3.0,1.0))*0.05+texture(iChannel0, (vec2(uv.x-0.2*t,-1.0*i+0.4*t))/vec2(1.0,0.5))*0.03;
        col =(1.6-3.0*c+vec4(-0.0,-0.4,0.0,1.0));
        
    	if (c.x>0.005*m-1.*uv.y+0.90){ col*=(1.0-0.5*i);break; }
        //uv.y+=ny;
    	//if (c.x>40.5*i*uv.y+0.94+20.9*i){ col +=mix(col,(0.4-c)*(0.8-i),1.); }

    }
	
    // Output to screen
    fragColor = col;
}