1 // Fragment shader code for metaball and background composition with refraction effect
3 precision mediump float;
4 varying vec2 vTexCoord;
5 uniform sampler2D sTexture;
6 uniform sampler2D sEffect;
10 vec4 metaColor = texture2D(sEffect, vTexCoord);
13 if (metaColor.r > 0.85)
15 zoomCoords = ((vTexCoord - 0.5) * 0.95) + 0.5;
17 else if (metaColor.r > 0.78)
19 float interpolation = mix(0.95, 1.05, (0.85 - metaColor.r) * 50.0);
20 zoomCoords = ((vTexCoord - 0.5) * interpolation) + 0.5;
25 zoomCoords = vTexCoord;
28 gl_FragColor = texture2D(sTexture, zoomCoords) * bright;