CG Texture Warping

Started by
0 comments, last by Lord_Evil 15 years, 3 months ago
Hello, I have a simple problem in OpenGL & CG. In my course project, I have to warp the texture that I have in the framebuffer. I managed to send the texture in the framebuffer to fragment shader and display it using tex2d, however, I have no idea on altering the texture coordinates. For instance, if I had a direction vector, how can I stretch the image in that direction? Any guides will be really helpful. Thanks a lot. PS: Sorry for my bad English.
Advertisement
Well, in the fragment shader you have the texture coords of the current fragment. Change them before calling tex2d, i.e. you move the coords along the given direction (taking some strechfactor into accoung, e.g. the length of the direction vector).

If you also employ a factor based on the texture coordinate you could get some stretching effect.

Or move the coords in the positve/negative direction based on their distance to some point/line, e.g. the center.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!

This topic is closed to new replies.

Advertisement