Skip to content

Instantly share code, notes, and snippets.

@tankorsmash
Forked from detunized/gist:1317940
Last active August 4, 2017 06:40
Show Gist options
  • Save tankorsmash/2abc606888086edb158c033e7a02d04f to your computer and use it in GitHub Desktop.
Save tankorsmash/2abc606888086edb158c033e7a02d04f to your computer and use it in GitHub Desktop.
Magnifying glass shader
// (c) 2011 detunized (http://detunized.net)
// Paste the shader below into http://shadertoy.com
// Click and drag the mouse around
#ifdef GL_ES
precision highp float;
#endif
uniform vec2 resolution;
uniform sampler2D tex0;
void mainImage(out vec4 fragColor, in vec2 fragCoord )
{
float R = 100.0;
float h = 20.0;
float hr = R * sqrt(1.0 - ((R - h) / R) * ((R - h) / R));
vec2 xy = gl_FragCoord.xy - iMouse.xy;
float x = xy.x;
float y = xy.y;
float r = sqrt(x * x + y * y);
vec2 new_xy = xy;
if (r < hr)
{
new_xy = xy * (R - h) / sqrt(R*R - r*r);
}
fragColor = texture(iChannel0, (new_xy + iMouse.xy) / iResolution.xy);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment