PDA

View Full Version : What's wrong with my texture mapping?



07-27-2000, 01:23 AM
I use texture mapping to do distortion effect of my program. However, the effect seems not uniform.
What are the correct flags I need to set?
original: http://www.cs.ust.hk/~yvonne/gl/e1.jpg\"
distorted: http://www.cs.ust.hk/~yvonne/gl/e2.jpg\"

pigpig
07-27-2000, 01:25 AM
I use texture mapping to do distortion effect of my program. However, the effect seems not uniform.
What are the correct flags I need to set?
original: http://www.cs.ust.hk/~yvonne/gl/e1.jpg"
distorted: http://www.cs.ust.hk/~yvonne/gl/e2.jpg"

lgrosshennig
07-27-2000, 02:08 AM
Hi there,

Enable perspective correct texturemapping.

Thats all.

Regards,

LG http://www.opengl.org/discussion_boards/ubb/biggrin.gif

Marc
07-27-2000, 06:58 AM
Is the distorted shape a square which is rotated in space or is it a flat object whose right vertices are pulled apart? For the latter there is no solution I think (I can be wrong).

dorbie
07-27-2000, 05:32 PM
This is not a perspective correction problem.

The polygons are not in perspective, the program is trying to apply a warp to the image using texture, it is failing because of it is not in perspective.

The solution is to use gltexcoord4* instead of gltexcoord2*, this will allow you to specify a 4th coordinate called 'w' which the hardware will use to weight the interpolation of the texture hardware and therefore avoid the kind in the image that you see. Start with a value of 1 for all coordinates and weight an edge based on relative length, that should do the trick.

Lgrosshennig, this is identical to perspective correction issues, but the key difference is the intent of the application and the way the triangle has been drawn.

john
07-27-2000, 05:38 PM
another solution is to subdivide the polygon further. It's linear texcoord interpolation problem, and if you make the linear segments smaller, then the error along them will be smaller, too.

cheers,
John

pigpig
07-28-2000, 12:10 AM
The whole image is one picture, I haven't repeat anything in it. And I only make this in a 2D-application.

When I changed from gltexcoord2* to gltexcoord4*, I got the same results. I set all the 3rd parameter to 0 and all the 4th to 1. Is that what u mean?