On the surface it just looks like the blend of 2 textures (your 2 images) based on a function of the eye-point to fragment vector. You will have the construct this function and pop it into the fragment shader

On the surface it just looks like the blend of 2 textures (your 2 images) based on a function of the eye-point to fragment vector. You will have the construct this function and pop it into the fragment shader

I tried but do not work very well, do you have any examples of how to do this?

Your lens will refract light and I assume you want to fly around this lens as it does so not simply stare through it.

You need to claculate the novel viewpoint and frustrum to generate the refracted image. Render that image to a texture and then apply that texture to the lens rectangle.

The simplest way to get the refraction is to raycast your rectangle corners through the lense rectangle according to Snell's law. Use the *EXIT RAYS* only and store these for all four corners. These four corner rays define your new frustum and will intersect at a novel view point. That Viewpoint's view direction should be orthogonal to the plane of the lens rectangle. From there you can compute the window of your frustum discarding the corner rays.

P.S. there are other simpler hacks that are not as accurate that you could also try that would not account for localviewer lens position, but simply use the existing rendered framebuffer image and readback. Or you could go more complex and implement non linear geometric distortions by subdividing the lens rectangle and applying additional corrections on a peicewise grid that warped the image you generated.