I am trying to build a shader that distorts the final image, to be more specific, it makes a wavy effect, kind of like this:
.
But when the object moves, its "geometry" moves around (think of a distorting mirror).
This
is the image I want to apply the distortion.
Now, it doesn't have to be random, it doesn't need to be localized in a specific area. Just a static sine pattern across the whole rendered image is what I am looking for.
When I searched google for this question, the closest I found was this thread. But the OP wants to apply the effect on a texture, which is not what I want. Either way, I tried to use the code, and I got this:
.
As you can see, the distortion was applied to the texture only and it works as a fixed texture and not to the scene as a whole. If I move the cube, the distortion acts as a texture, and move with the cube. Not really like a distorting mirror.
I also found out that I can't change the coordinates of the pixel on the fragment shader, for example, make that the pixel where the cube is, be more on the top, or more on the bottom (like the sine curve). The fragment shader just chooses the color where the fragment was rasterized.
So, is it even possible to do this kind of effect with GLSL shaders? If so, how?