[size=2]As a first go at a journal entry, just a simple topic:
For a feature for my little 3d painting app, I wanted to be able to warp source images to make them fit better onto 3d models. Never having done image warping before I quickly came to what I presume is the basis for how most people do it...
For a given source image, I created a corresponding sized 2d array of 2D vector floats, I'll call a 'vector map':
Each vector represents a displacement (in pixel space) to find the source pixel for each destination pixel in the resulting image.
So the process to create the final image is as follows:
[font=arial]Loop through all the destination pixels[/font]
[font=arial]For each xy, look up the corresponding vector in the vector map.[/font]
[font=arial]Add the vector to xy, to get a float source xy.[/font]
[font=arial]Look up the source pixel from the source image (using texture filtering if desired)[/font]
[font=arial]Copy the source pixel to the xy destination.[/font]
Here is an example, using a simple circle brush, with vector direction and magnitude depending on distance from the centre:
And here is a more subtle brush just pushing in the direction of mouse drag:
It also occurs to me that it is fairly easy to extend this vector map to use systems such as a guidance mesh, or anchor and pull points. These could perhaps be done faster by other more direct methods, but as this is not CPU critical in my case it would fit the bill, and is very flexible.