Skip to content

Instantly share code, notes, and snippets.

@ds0nt
Created August 1, 2016 13:50
Show Gist options
  • Save ds0nt/065cd747a234a7a30f233ec07e638b68 to your computer and use it in GitHub Desktop.
Save ds0nt/065cd747a234a7a30f233ec07e638b68 to your computer and use it in GitHub Desktop.
<script type="x-shader/x-fragment" id="sky-fragment">
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 vUv;
uniform float time;
//3.141592654
float hash( float n )
{
return fract(sin(n)*43758.5453);
}
float noise( vec3 x )
{
// The noise function returns a value in the range -1.0f -> 1.0f
vec3 p = floor(x);
vec3 f = fract(x);
f = f*f*(3.0-2.0*f);
float n = p.x + p.y*57.0 + 113.0*p.z;
return mix(mix(mix( hash(n+0.0), hash(n+1.0),f.x),
mix( hash(n+57.0), hash(n+58.0),f.x),f.y),
mix(mix( hash(n+113.0), hash(n+114.0),f.x),
mix( hash(n+170.0), hash(n+171.0),f.x),f.y),f.z);
}
void main( void ) {
float depth = 1.0-(abs(0.5 - vUv.y) * 4.0);
float a = noise(vec3(vUv.x, vUv.y, 1.0));
float a2 = noise(vec3(vUv.x * 10.0, vUv.y * 10.0, 1.0));
float a3 = noise(vec3(vUv.x * 40.0, vUv.y * 40.0, 1.0));
float a4 = noise(vec3(vUv.x * 760.0, vUv.y * 260.0, 1.0));
float x = vUv.x + cos(a + a2 / 10.0 + a3 / 40.0 + a4 / 160.0);
float y = vUv.y + sin(a + a2 / 10.0 + a3 / 40.0 + a4 / 160.0);
float intense = abs(mod(cos(x * 3.141592654 * 10.0), 0.4)-0.2);
intense += abs(mod(cos(x * 3.141592654 * 10.0), 0.4)-0.2);
intense += abs(mod(cos(x / 4.0 * 3.141592654 * 10.0), 0.4)-0.2);
intense += abs(mod(cos(x / 16.0 * 3.141592654 * 10.0), 0.4)-0.2);
intense += abs(mod(sin(y * 3.141592654 * 10.0)*10.0, 0.4) - 0.2);
intense += abs(mod(sin(y / 4.0 * 3.141592654 * 10.0)*10.0, 0.4) - 0.2);
intense += abs(mod(sin(y / 16.0 * 3.141592654 * 10.0)*10.0, 0.4) - 0.2);
intense += abs(mod(sin(y / 64.0 * 3.141592654 * 10.0)*10.0, 0.4) - 0.2);
intense = pow(intense, 2.0);
//float waver = 0.06 * -vUv.y * sin(vUv.x * 3.141592654 * 12.0 );
float blue = 1.0*intense;
float red = 0.66*intense;
float green = 0.11;
vec4 color = vec4(
(intense * ((red * depth))),
depth* intense * green,
(intense * 1.5 * ((blue * depth))),
1.0
);
gl_FragColor = color;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment