scene.org File Archive

File download

<root>­/­parties­/­2016­/­tokyodemofest16­/­glsl_graphics_compo/happy_face.txt

File size:
2 257 bytes (2.20K)
File date:
2016-02-24 05:45:01
Download count:
all-time: 406

Preview

#ifdef GL_ES
precision mediump float;
#endif

#extension GL_OES_standard_derivatives : enable
#define PI 3.1415926535

uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;

float rand(float a, float b)
{
    return fract(sin(dot(vec2(a, b) ,vec2(12.9898,78.233))) * 43758.5453);
}

void main( void ) {

	vec2 pos = ( gl_FragCoord.xy - resolution.xy / 2.) / resolution.y + mouse - 0.5;
	
	vec3 color = vec3(0, 0, 0);
	
	for(int i = 0; i < 200; i++)
	{
		float fi = float(i);
		float t  = pow(fract(time * 2.), 0.5);
		float t2 =     floor(time * 2.);
		float a = float(i) / PI;
		float len = 0.3 + (1. - t) * 0.2 * rand(fi, t2);
		vec2 p = pos + vec2(cos(a), sin(a)) * len;
		float intencity = pow(0.003 / length(p), 1.5);
		color += intencity * vec3(rand(fi, 1.), rand(fi, 2.), rand(fi, 3.));
	}
	for(int i = 0; i < 20; i++)
	{
		float fi = float(i);
		float t  = pow(fract(time * 2.), 0.1);
		float t2 =     floor(time * 2.);
		float a = float(i - 10) / PI / 5.;
		float len = 0.3 + (1. - t) * 0.2 * rand(fi, t2);
		vec2 p = pos + vec2(sin(a), cos(a)) * len;
		p += vec2(0, -0.1);
		float intencity = pow(0.003 / length(p), 1.5);
		color += intencity * vec3(rand(fi, 1.), rand(fi, 2.), rand(fi, 3.));
	}
	for(int i = 0; i < 20; i++)
	{
		float fi = float(i);
		float t  = pow(fract(time * 2.), 0.1);
		float t2 =     floor(time * 2.);
		float a = float(i - 10) / PI;
		float len = 0.04 + (1. - t) * 0.2 * rand(fi, t2);
		vec2 p = pos + vec2(sin(a), cos(a)) * len;
		p += vec2(-0.13, -0.05);
		float intencity = pow(0.003 / length(p), 1.5);
		color += intencity * vec3(rand(fi, 1.), rand(fi, 2.), rand(fi, 3.));
	}
	for(int i = 0; i < 20; i++)
	{
		float fi = float(i);
		float t  = pow(fract(time * 2.), 0.1);
		float t2 =     floor(time * 2.);
		float a = float(i - 10) / PI;
		float len = 0.04 + (1. - t) * 0.2 * rand(fi, t2);
		vec2 p = pos + vec2(sin(a), cos(a)) * len;
		p += vec2(0.13, -0.05);
		float intencity = pow(0.003 / length(p), 1.5);
		color += intencity * vec3(rand(fi, 1.), rand(fi, 2.), rand(fi, 3.));
	}
	color += vec3(fract(pos.y * 20. + time) < 0.5) * 0.05;
	color += vec3(fract(pos.y * 20. - time) < 0.5) * 0.05;
	gl_FragColor = vec4(color, 1.0);

}