Page 1 of 1

Q4: errors in tex coord generation for patches?

Posted: Sun Mar 05, 2006 3:25 am
by Johnny Law
In Q3, I remember that if I needed a warped/skewed/stretched texture on a surface, I could make a patch mesh to do so. Either by fitting the texture on a rectangular patch and then warping the patch control points around, or else by creating the patch in the desired shape first and then applying the texture and directly messing with the S and T values of the control points.

At least, I _think_ I remember being able to do that!

In Q4, it ain't happening. The texture seems to be correct along the outer edges of the patch, but in the middle it is oddly goofed up.

One example is the "grill"-type textures on either side of the light here: http://www.neogeographica.com/temp/warped_patch_1.tga

The patch each of these textures is applied to, is a patch with a straight top edge but an angled-down bottom edge. If I fit the texture to this patch I would expect the grill lines in the texture to angle down more and more as they near the bottom. They generally do this, but they also get warped as you can see.

Another example, the trapezoidal mesh a little lower than the crosshair in this image: http://www.neogeographica.com/temp/warped_patch_2.tga

This started life as a rectangular mesh with the lines on it being straight. I moved 6 of the control points to make it trapezoidal, and the texture is now all crazy in the middle of the patch.

In this second example I checked the .map file before and after moving the mesh control points, and the S and T values are still the same for each control point. So it seems like something is going awry in the generation of texture coordinates. Or else I'm hitting some sort of mental block with a dumb mistake in here somewhere.

(Here's an in-editor view of the patch control points for the second example, just to show there's nothing bizarre going on with them: http://www.neogeographica.com/temp/patc ... points.gif)

Anyway, please lemme know if there's something I can do to fix this behavior ... or if I should stop even trying to make something like this work. :)

Posted: Sun Mar 05, 2006 4:40 am
by Kat
Unfortunately it appears the only good way to fix this is to increase patch subdivisions to distribute the UVWmapping over more polygons.

A side note, try not to post tga images, they're usually massive for their size and you have to have quicktim installed to view them avec browser.

Posted: Sun Mar 05, 2006 4:45 am
by pjw
When you have a flat patch that's not axial, you'll need to manually knock up the subdivisions via the surface inspector to get rid of the texture skewing.

Subdivisions are treated as 1/1 on a square-edged planar patch by default to produce fewer tris--thus the b0rkage. Pull some verts and force a curve on at least one edge of the patch and you'll see the texture immediately "snap" into place and (more or less) fix itself, even though the patch is still planar. No curves = manually subdivide.

Edit: beaten. :)

Posted: Sun Mar 05, 2006 5:08 am
by Johnny Law
Interesting. Maybe I was remembering something on a more curvaceous patch. I went and tried this in GtkRadiant just now and it appears that Q3 has this same behavior too, at least in the editor. (Presumably the in-engine behavior follows.)

Thanks...

Posted: Sun Mar 05, 2006 5:25 am
by Johnny Law
Kat wrote:A side note, try not to post tga images, they're usually massive for their size and you have to have quicktim installed to view them avec browser.
Aheh... sorry! I didn't post them inline because I hadn't compressed them, but I didn't actually check the filesize. Apologies if you got a nasty surprise when you clicked. I'll be more careful next time. :)