CMH Studio

Imperfect Circle

A simple circle with a glow effect.


#ifdef GL_ES
precision mediump float;
#define GLSLIFY 1
#endif

uniform vec2 u_resolution;
uniform float u_time;
uniform vec2 u_mouse;

#define GLSLIFY 1
vec2 hash2( vec2 x )        //亂數範圍 [-1,1]
{
    const vec2 k = vec2( 0.3183099, 0.3678794 );
    x = x*k + k.yx;
    return -1.0 + 2.0*fract( 16.0 * k*fract( x.x*x.y*(x.x+x.y)) );
}

float gnoise( in vec2 p )   //亂數範圍 [-1,1]
{
    vec2 i = floor( p );
    vec2 f = fract( p );
    
    vec2 u = f*f*(3.0-2.0*f);

    return mix( mix( dot( hash2( i + vec2(0.0,0.0) ), f - vec2(0.0,0.0) ), 
        dot( hash2( i + vec2(1.0,0.0) ), f - vec2(1.0,0.0) ), u.x),
        mix( dot( hash2( i + vec2(0.0,1.0) ), f - vec2(0.0,1.0) ), 
        dot( hash2( i + vec2(1.0,1.0) ), f - vec2(1.0,1.0) ), u.x), u.y);
}

float fbm(in vec2 uv)       //亂數範圍 [-1,1]
{
    float f;                //fbm - fractal noise (4 octaves)
    mat2 m = mat2( 1.6,  1.2, -1.2,  1.6 );
    f   = 0.5000*gnoise( uv ); 
    uv = m*uv;		  
    f += 0.2500*gnoise( uv ); 
    uv = m*uv;
    f += 0.1250*gnoise( uv ); 
    uv = m*uv;
    f += 0.0625*gnoise( uv ); 
    uv = m*uv;
    return f;
}

float glow(float d, float str, float thickness){
    return thickness / pow(d, str);
}

void main() {
  vec2 st = gl_FragCoord.xy/u_resolution.xy;  //[0,1]
  //st.x *= u_resolution.x/u_resolution.y;    //[0~1.33]
  vec2 uv = st*2.0-1.0;                       //[0,1] -> [-1,1]
  //uv.x *= u_resolution.x/u_resolution.y;    //[-1.33~1.33]
  
  float distance = length(uv)+0.4*fbm(uv*2.008);
  //sqrt(uv.x*uv.x+uv.y*uv.y)

  float circle_dist= abs(distance-0.380);
  //float breathing= sin(u_time/2.0*3.14159)*0.2+0.5; //[0.3, 0.7]
  float breathing= mix(0.3, 0.7, 
      sin(u_time/2.0*3.14159)*0.5+0.5);               //[0.3, 0.7]
  float glow_circle= glow(circle_dist,breathing,0.074);

  //亂數作用雲霧
  float fog= fbm(0.4*uv+vec2(-0.2*u_time, -0.02*u_time))*0.6+0.1;
  vec3 color = vec3(glow_circle+fog)*vec3(1.000,0.348,0.006);
  
  // return color;
  gl_FragColor = vec4(color,1.0); 
}

Pluto

Pluto (minor-planet designation: 134340 Pluto) is a dwarf planet in the Kuiper belt.

History

In the 1840s, Urbain Le Verrier used Newtonian mechanics to predict the position of the then-undiscovered planet Neptune after analyzing perturbations in the orbit of Uranus.


Just a link: www.nasa.gov.

  • Lists
  • todo
  • done

A table:

ab
Show example
console.log('Hi pluto!')