I am making simple distortion effect in a 2D space. The distortion is simple as I am mapping the image to a quadrilateral. When I distort the first image to the shape of the second, the result is not uniform. It seems like splitting up the image into 2 triangles to do the transformation. How can I solve this problem?
no, it shouldn’t (and won’t) do the trick. perspective won’t work in 2D space!! (besides, it’s only a hint)
sub-divided the polygon. minimise the linear interpolation error.
Yes, bilinearly interpolate the xy and uv space on that polygon.
Wasn’t there another thread which already handled that problem.
To get the distortion solved you’ll have to issue 4D texture coordinates on the vertices with the last paramter q from (s, t, r, q) holding the informations for the algorithm to do “perspective correction” which in your case is not occuring because it’s just plain flat, only distorted.
So the $100,000 question is now, how do you get the correct q values?
I haven’t done that before, but I would code the distortion into an 4x4 shear matrix and feed 4D vectors through it, and would feed the homogenous coordinate w into the texture as q=1/w.
Sorry, I’ve no idea if that stuff above is working or if q=w. I would have to look up the specs, but I’m too lazy right now.
But the 4D texture coordinates are a must to solve your problem.
[This message has been edited by Relic (edited 08-02-2000).]
what exactly do you want to do? I’ve done 2D distortions before, and the way I did it was apply a warp mesh (of arbitary high resolution to avoid the bilinear interploation problem you’ve been describing) over the frame buffer. But that might not be what you want…
I need to perform some free transformation on rectangular image to form any quadrilateral shape. I am seeking for some methods that involve less calculation and that can use OpenGL built-in functions as much as possible.