Quad UV Question
Blitz3D Forums/Blitz3D Programming/Quad UV Question
| ||
Maybe a stupid question... I have a problem, when I create a quad from two Triangles, I can easily assign a texture to it, using UV coords 0.0 to 1.0. But when I now try to use some kind of expanding shape, the UV mapping is messed up. Can this be solved somehow? A is how it should look and B is how it looks. |
| ||
I'm not all that up on u/v coords, but dont they say where in the texture a particular vert gets its tex data ? if you move a point, and want the texture to stay consitent, dont you also have to move the u/v coords ?? |
| ||
The UV should be no problem, at least if you assigned the UV when you added the vertices. But when you didn't set them because the vertexcoords were in UV like range, then they can be messed up after scale operations so far I never had any problems with my dynamically created meshes ( for terrain for example ) |
| ||
seems like I got to explain this further in the first quad you see two tris, let's say this is something like v0=AddVertex(surf,-1.0,-1.0,0, 0,0) v1=AddVertex(surf, 1.0,-1.0,0, 1,0) v2=AddVertex(surf, 1.0, 1.0,0, 1,1) v3=AddVertex(surf,-1.0, 1.0,0, 0,1) AddTriangle(surf,v0,v1,v2) AddTriangle(surf,v2,v3,v0) So far everything is ok. but when I use: v0=AddVertex(surf,-1.0,-1.0,0, 0,0) v1=AddVertex(surf, 1.0,-1.5,0, 1,0) v2=AddVertex(surf, 1.0, 1.5,0, 1,1) v3=AddVertex(surf,-1.0, 1.0,0, 0,1) ...instead, and I would expect to get something like the A Pic, I get what's shown on Pic B! So what would I have to do to tell the vertices that they should not map the texture parallely to the first 2 UV coords ? I am sure some of you had exactly this problem before, so I guess it's clear what I am talking about. |
| ||
as long as the order is clockwise around the normal, it doesnt matter which vertex you start at when you add the tri. |
| ||
This might be true, but it doesn't have anything to do with my problem as far as I see. So this problem still has to be solved, please help me. |
| ||
jfk: "So what would I have to do to tell the vertices that they should not map the texture parallely to the first 2 UV coords ? " change the 1st two coords by changing the order :) I'm just guessing here -- I really dont know how u/v texture mapping works internally |
| ||
nah - swapping the uv-coords would only mirror the texture. The problem is, a quad is made of 2 tris. Each tris has 3 UV coords. They are the 3 corners of the texture. now when I distort one corner, the triangle "thinks" I was distorting not only one corner, but also a virtual forth uv coodinte, that was never defined. That's the problem. In fact I needed a forth UV coordinate that can be defined freely for each Triangle to map it correctly. Or I would have to use built in Quads, which would support this by default. Well, at least I think I needed such a forth, "virtual" UV Coordinate for each Triangle. But maybe there is an other way. At least, all tools I know (eg. Lithunwrap etc.) use Triangulized Meshes and can do this kind of scaling without any problems - AFAIR. But thanks anyway, ZombieWoof - good to see somebody is trying to help. |
| ||
Try this to see what jfk is talking about... I have never found away around this problem with tris, if only we could use real quads. |
| ||
I think I understand what you mean, and I don't know of a way to fix the situation. Because there's only 3 UVs on a Tri, you can't stretch the texture un-naturaly :/ Tom |
| ||
Have you tried altering the UV coord to match the vertex scale? For example: v0=AddVertex(surf,-1.0,-1.0,0, 0,0) v1=AddVertex(surf, 1.0,-1.5,0, 1.5,0) v2=AddVertex(surf, 1.0, 1.5,0, 1,1.5) v3=AddVertex(surf,-1.0, 1.0,0, 0,1) I don't have time to go into great depth, but since your verts don't overlap (y = -1.0 and y = -1.5), changing the UV scale is the only way to fix it. It may not work out to be an exact translation so you may need a value of 1.2 or even 0.9 or something. Mess around with the UV numbers...I'll bet you get it going. |
| ||
I'll bet you get it going. How much? ;) If you set the UV to 1.5 you will end up with the texture tiled one and a half times. |
| ||
Interesting problem. I don't have a solution, but just to say, if you don't want any tiling or leaving out of texture data then you can't change the UVs. The only thing I can think of is transformin the actual texture. |
| ||
You might be able to get around this by using 5 vertices and 4 tris, putting an extra vertex in the center and calculating its new UV offset (depending on where the corner vertices are). But you'll probably still see some "bending" in the texture. Not much of a solution I know. |
| ||
Did I understand you correctly? Here's a pic from Photoshop showing a distorted texture, I've overlayed some lines to represent the polys: If this 'is' what you mean, then there's no way I know to fix it. In the bottom most texture, the bottom left Tri would need some magical 4th UV to let the gfx card know it should be stretched :/ Tom |
| ||
try it the other way -- starting from the perfect square, move the bottom right point and see how it looks :) If it turns out Ok, you need to add a center point and split into 4 tris.. the center point is always the intersection of the lines between opposite corners. |