Hi.
So I am aiming for something like that OP of this thread wanted but never got:
construct.net/en/forum/construct-2/effects-31/discussion-lens-effect-126987
The problem in question is the old, native Lens Effect.
Lens Effect distorts and magnifies everything under the bitmap using pixel brightness and transparency. So, in theory - 100% transparent pixels do nothing but opaque white pixels - will magnify.
The problem with the effect is that it also takes into consideration the position on the screen and the magnifying is always based on the center of the screen, instead of the center of the object with the effect.
I am pretty sure it can be easily fixed by just changing the variables the centering is using. Sadly - I never got into GL shaders and I don't know how to do it by myself :/
Anyone? Gigatron - are you still around old friend?
/////////////////////////////////////////////////////////
// Lens effect
varying mediump vec2 vTex;
uniform lowp sampler2D samplerFront;
uniform lowp sampler2D samplerBack;
uniform mediump vec2 destStart;
uniform mediump vec2 destEnd;
uniform mediump float pixelWidth;
uniform mediump float pixelHeight;
uniform mediump float magnification;
void main(void)
{
lowp vec4 front = texture2D(samplerFront, vTex);
// Lens distort
mediump float zoomFactor = (0.5 - (front.r * 0.299 + front.g * 0.587 + front.b * 0.114) * magnification) * front.a;
mediump vec2 center = (destStart + destEnd) / 2.0;
mediump vec2 p = vTex;
p += (vTex - center) * zoomFactor;
gl_FragColor = texture2D(samplerBack, mix(destStart, destEnd, p));