I am rather new to (Modern) OpenGL, only taking my first steps with shaders. I was given the task to make it possible to use a mesh warp to warp the OpenGL window content. So, for example, given the simple Hello Triangle program from the LearnOpenGL website, what I want to do is the following:
Given a rectangular 32x32 mesh of gridpoints that is originally nicely fitting our main window, we move all the meshpoints to another location so that we have some kind of ‘displacement field’, and then the new mesh point locations determine the ‘main window warp’. Something like the following:
However, ‘Original image’ should not just be a static image, it should be my ‘dynamic OpenGL window content’. So for example if I’ve created a simple application that allows me to move with my mouse in a 3D space within that window, after the warping I should be moving in the ‘warped 3D space’, where the warp is defined by the warping mesh.
Clearly, only the warped locations of all 32x32=1024 mesh points are exactly defined. For all pixels in between, I assume some kind of interpolation method will be necessary or so.
I have read about the vertex shader and the fragment shader. Is this something that can be done completely in one of these shaders? Having some hints on how to approach this would be welcome.