Skip to content

Instantly share code, notes, and snippets.

@codehz
Created September 12, 2016 12:51
Show Gist options
  • Save codehz/4628f795560afb64b28bf635f4dca8d1 to your computer and use it in GitHub Desktop.
Save codehz/4628f795560afb64b28bf635f4dca8d1 to your computer and use it in GitHub Desktop.
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
uniform vec2 resolution;
uniform vec2 offset;
uniform sampler2D backbuffer;
uniform vec3 gravity;
uniform float time;
uniform int pointerCount;
uniform vec3 pointers[10];
uniform sampler2D github;
uniform float light;
uniform vec3 linear;
float scale = 16.0;
float radius = 40.0;
float ovalue = 1000.0;
float gvalue = -10.0;
float motion = 0.1;
float envlight = min(pow(light / 128.0 + 0.1, .5), 1.0);
float lightpower = 2.0;
float lightparam = 1.5;
float lightextend = 0.01;
void main( void )
{
float mi = min( resolution.x, resolution.y );
float mx = max( resolution.x, resolution.y );
vec2 vxy = gl_FragCoord.xy + gvalue * gravity.xy;
vec2 xy = floor(vxy / scale) + 0.5;
vec2 dxy = xy * scale - vxy;
float l = envlight - length(dxy) / radius * envlight;
for(int i = 0; i < pointerCount; i++)
l += lightpower / pow(length(gl_FragCoord.xy - pointers[i].xy) * lightextend, lightparam);
gl_FragColor = vec4(
mix(texture2D(backbuffer, gl_FragCoord.xy / resolution.xy).rgb,
mix(vec3(0.0, 0.0, 0.0),
texture2D(github, (xy * scale + ovalue * offset) / mi).rgb, l),
motion), 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment