There's a nicer way... without all those verticles/stuff
1.Create a warp map (32bpp will do fine), warp map is the size of real image
Now the 32bits represent two 16bits numbers. The X movement and Y movement. Store them with some additional precision, 12:4 fixedpoint number will do fine.
2.Fill warp map with data,
So for each pixel on screen you fill the 32bit data with something like
x=16 y=-16 (means this pixel will be taken from one place right and one place above - remember we use 12:4 fixedpoint number)
3.modify image using warp map
you simple do a loop like
- Code:
newimage[x,y]=oldimage[x+((warp[x,y].x)>>4),y+((warp[x,y].y)>>4)]
of course this is without using fixedpoint math, in reality you should do bilinear interpolation using the fraction bits for good quality
4.Tricks
of course you don't need to recalculate warp map every time.. you can calculate it once and use few times
another thing is that you can generate warp data on fly without a warp map (like if you want to use sin/cos or similar waves you can simply precalculate sin in range 0-2pi and then use this data to calculate warp data on the fly.
This should be possibly for your needs (something like a modified shape sin/cos wave should be perfect)
5.Results
This methods gives good quality and fine speed results (assuming bilinear is used). Without bilinear performace is better but quality suffers.
6.Propsed solution
I guess you would be fine with on the fly calculated data, sth like code above which uses sin waves and normal pixel copy (no bilinear)
sin is a 8:8 fixedpoint number so 256==1.0f etc.
variables used:
t-time
image - your image
newimage - your image after warp
x,y
- Code:
for x
for y
newimage[x,y]=oldimage[x+(sin[((t+x)&0xff)]>>4),y+(cos[((t+y)&0xff)]>>4)]
end for
end for
this should give you a 16pixels wave over your image which changes with time... this is the simplest effect possible... you need to add some checks so you don't try to grab pixels from position -5,-5 etc.
if you have got some questions (probably you do, chaotic explanation at 1 o'clock in the night

let me know