CG Texture Warping
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.
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 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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement