Delgine 3D Tools & Content DeleD Community Edition
Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

UV Mapping a wooden pole...
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Community Edition
View previous topic :: View next topic  
Author Message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Thu Aug 02, 2007 11:32 am    Post subject: UV Mapping a wooden pole... Reply with quote

Here is an e-mail I got (I cut out the images):

Quote:
Basically im mapping using deled.

Im having trouble mapping.
All i really want to be able to do is be able to planar map from x,y,z axis so as to be able to accurately map stuff.
Box mapping just isnt cutting it, For one thing i dont see any weld uv tools so its messing my tiling up bad.
Planar map from all axis would help cover this up bigtime.
At the moment it seems to only planar map from the side.

I attached pictures of the uv layout i have done in max and deled.
The max picture is what i am trying to attain, The deled is what i have got.
The main problem is trying to map the pointy bit at the top of the pole

Is there are tools ior techniques i should know about?

Im coming from a max background.


Last edited by Paul-Jan on Thu Aug 02, 2007 12:21 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Thu Aug 02, 2007 12:19 pm    Post subject: Reply with quote

Our UV Editor is still very barebones, no fancy wrappings yet, so you'll have to do everything by hand. And even that could do with some more convenience tools. These are all things we will improve in the future, but for now, let's do things the old fashioned elaborate way.

Here is the basic pole model we are going to map. I just used a 2 segmented cylinder, pulled up the edge to make the upper segment smaller, then grapped the vertices on the top and scale them together to make the pointy bit.



Now by the looks of it, this model would be a perfect match for a cylindrical mapping. However, DeleD doesn't have a cylindrical maping yet, and the default box mapping will map the sides of the pointy bit to 4 different sides of the box, which is a pain to correct.

Because we don't have the right mapping for the job, we'll work the other way around: let's adapt the model to the mapping first and correct afterwards. Select the vertices of the pointy tip and pull them down to the start of the pointy part, effectively creating a flat cylinder.



Now generate the box mapping (right mouse menu). It's not perfect yet, but at least the pointy part is now a nice circle-shape. In the image below I've drawn some ugly arrows to show where I moved all the different parts.



The sides of the body of the pole are still separate, so we have to manually match them up. To do so, I usually close all viewports but the 3D and UV mapping viewport and make them as large as possible.

We also move the top and bottom (circular parts) to the correct locations and scale them (keep CTRL pressed to keep the aspect ratio fixed) to match up with the texture. The result will look something like this:



Now from the top view, grab the vertices of the tip again and pull them out. The result will be nicely mapped:



You might notice there is still a seam left in the texture map (the left and right sides of the maping of the pole's main body). If you use a texture that nicely repeats from left to right, and scale up the body part mapping to exactly match the width of that subtexture, the seam should practically disappear. For pixel-perfect results you might want to copy a small amount of pixels from the left and add it to the right, so even the texture filtering matches up.

I don't have time for all that now, and my model looks poor anyway because I have no artistic skills whatsoever. Just hope the techniques are clear! If there are any questions, just ask away...
Back to top
View user's profile Send private message Visit poster's website
elementrix
DeleD PRO user


Joined: 11 May 2006
Posts: 1300
Location: The Netherlands

PostPosted: Thu Aug 02, 2007 1:13 pm    Post subject: Reply with quote

Quote:
The sides of the body of the pole are still separate, so we have to manually match them up. To do so, I usually close all viewports but the 3D and UV mapping viewport and make them as large as possible.


with this a funtion like weld vetices (for uv editor) would be awesome and you said you were going to implent it:

http://www.delgine.com/forum/viewtopic.php?t=2039

when do you think this tool will be available?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Thu Aug 02, 2007 6:17 pm    Post subject: Reply with quote

Can't be more precise than 'not in the immediate future, but not in the distant future either".

I'm sorry about that, but because of the holiday season and the lack of available manpower we kinda stopped roadmapping beyond our immediate planning, as we can't make realistic guesses anyway. Current planning = getting the 1.71 release out the door somewhere next week.
Back to top
View user's profile Send private message Visit poster's website
TenTerHooK
Member


Joined: 28 Mar 2007
Posts: 12

PostPosted: Fri Aug 03, 2007 5:40 pm    Post subject: Reply with quote

Thanks for the help so far. Its been great and my mapping has improved greatly.

But I found some errors when exporting to Torque which is the engine I am using. If I use one texture to map the top and sides of pole the mapping is way of even though it looks fine in deled.

I fixed this by seperating the textures and it worked out fine for the sides of the pole, but the tiling on the top is still of and I have no idea why. It looks fine in deled.





But when I export to Torque the tiling goes bad for some reason.




I dont know if this is map2dif messing things up on me or what... and I was so close!
Back to top
View user's profile Send private message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Mon Aug 06, 2007 3:58 pm    Post subject: Reply with quote

Aha, Torque!

The short story: The Torque Exporter is to blame, it doesn't export the texturing properly. We should fix it.

The long story: The .map file format doesn't use UV coordinates, it uses so-called "texture axes" to record the mapping of the texture onto the plane. Which is nice and dandy, but I don't know how to map an arbitrary set of UV coordinates on said texture axes, and I can't seem to find any good information either. I'll see if I can fix things for this specific situation... but if you know any other polygon -> .map/.dif exporter that properly handles UV coordinates properly I might be able to learn from it.

I'll see what I can do, thanks for reporting the problem!
Back to top
View user's profile Send private message Visit poster's website
jwatte
DeleD PRO user


Joined: 26 Apr 2006
Posts: 513

PostPosted: Mon Aug 06, 2007 6:24 pm    Post subject: Reply with quote

Quote:
I don't know how to map an arbitrary set of UV coordinates on said texture axes


For a given triangle, that's just a linear equation system.

You want, for the triangle V1/V2/V3 the coordinates U1/V1, U2/V2 and U3/V3.

Ax*V1x + Ay*V1y + Az*V1z + Ac = U1
Ax*V2x + Ay*V2y + Az*V2z + Ac = U2
Ax*V3x + Ay*V3y + Az*V3z + Ac = U3

Bx*V1x + By*V1y + Bz*V1z + Bc = V1
Bx*V2x + By*V2y + Bz*V2z + Bc = V2
Bx*V3x + By*V3y + Bz*V3z + Bc = V3

You're searching for Ax/Ay/Az/Ac for the U axis, and Bx/By/Bz/Bc for the V axis. You can see that you have three equations and are looking for four unknowns, so you can set Ac and Bc to 0 (or any other constant you choose). Note that the equation (axis) for U is independent from the equation (axis) for V.

These equation systems will give you the desired U,V coordinates at each of the vertices V1,V2,V3. Because of the linear interpolation property of triangles, the pixels in the middle will also behave.

Plug into your favourite matrix inversion routine, and you're done! Or use Gaussian elimination if you're so inclined.

Perhaps the reason you can't find reference material is that, to someone who doesn't know Linear Algebra, this looks big-scary, and to anyone who has taken Linear Algebra 101, this looks like a mid-term exam question :-)

Unless I'm making a mistake, and will have to come back apologizing and looking the fool, of course :-)
Back to top
View user's profile Send private message
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Mon Aug 06, 2007 8:52 pm    Post subject: Reply with quote

*lol* Well, to be honest, this was the first solution I tried, but when
a) It didn't work 100% and
b) I realized I wasn't all that sure that was the way the "texture axis" in the .map format worked anyway (why all the redundancy? There is scale and rotation too, although as I understand it rotation isn't used at all in the Torque setting) and
c) I peaked inside the sources of some other plugin (probably the Blender .map exporter) and a similar solution was commented out for not working...

... I kinda gave up on that route to look for more info. However, if those are indeed the equations (you seem to be pretty sure), I probably just have some errors in my implementation. I'll give it another look. If you are correct, I'll be a very grateful man... Very Happy
Back to top
View user's profile Send private message Visit poster's website
TenTerHooK
Member


Joined: 28 Mar 2007
Posts: 12

PostPosted: Tue Aug 07, 2007 3:22 pm    Post subject: Reply with quote

I personally would really appreciate being able to uv map bsp structures like they where 3d models. Its one of the big limitations on this format in my eyes.

Really lowers the potential with the format.

If anybody knows of a workaround please let me know.
Back to top
View user's profile Send private message
jwatte
DeleD PRO user


Joined: 26 Apr 2006
Posts: 513

PostPosted: Wed Aug 08, 2007 7:18 pm    Post subject: Reply with quote

Well, those are the equations for what "texture axes" usually mean. No idea what perversions they may be using for Torque .map files.

Although I am a Torque licensee, so I can take a look in interiorMap.cc...

OK, the coordinates seem to be in pixels, because the first thing that happens is dividing by texture map size to normalize to 0/1. That's a problem if you want to build with one resolution, but deploy with another.

Then the texgens are scaled by something called "brushscale" in the map format.

Then, the texture coordinate generated is just x*a+y*b+z*c+d for the world-space position. There's a separate texgen, that works the same, for light mapping, too.

In the Valve 220 parser, there is an additional scaling factor which affects a, b, c but not the d term.

Last, make sure you use the same "up" as they do :-) The texture T/V coordinate goes from first byte towards last, but the default JPG/PNG loaders deliver the top scanline first, but the default TGA/BMP loaders deliver the last. You probably have code for this already.

Note: this description goes from the rendering and backwards in the pipe, describing how each intermediary value is determined.
Back to top
View user's profile Send private message
Daaark
DeleD PRO user


Joined: 01 Sep 2004
Posts: 2696
Location: Ottawa, Canada

PostPosted: Wed Aug 08, 2007 9:13 pm    Post subject: Reply with quote

What is it with Torque and all these funny 'solutions'?
_________________
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
trucker2000
DeleD PRO user


Joined: 11 May 2005
Posts: 1839
Location: Sacramento, California

PostPosted: Thu Aug 09, 2007 2:01 am    Post subject: Reply with quote

Daaark wrote:
What is it with Torque and all these funny 'solutions'?

It was written in the old days where the Z axis was up/down.
_________________
Some day I will grow up and be a real modeler.
"Never give up! Never surrender!!"
Sys specs:
asus
8 gigs ram
Invidia gtx560 video card
Windows 8 (worst op sys Ever)
Back to top
View user's profile Send private message Visit poster's website
jwatte
DeleD PRO user


Joined: 26 Apr 2006
Posts: 513

PostPosted: Thu Aug 09, 2007 11:35 am    Post subject: Reply with quote

Up/down doesn't matter to any 6dof engine. The problem with Torque is that it uses the .MAP format, which was written back in the software renderer days, where texgen axes interpolated easier than explicit texture coordinates, and texture coordinates in pixels instead of normalized to 0..1 saved a multiply per texture look-up.
Back to top
View user's profile Send private message
jwatte
DeleD PRO user


Joined: 26 Apr 2006
Posts: 513

PostPosted: Fri Aug 10, 2007 11:39 am    Post subject: Reply with quote

OK, in PM we figured out what the fourth equation is to make the system fully determined. The U and V coordinates should not vary in the direction of the face normal. Thus, the full solution looks like:

Ax*V1x + Ay*V1y + Az*V1z + Ac = U1
Ax*V2x + Ay*V2y + Az*V2z + Ac = U2
Ax*V3x + Ay*V3y + Az*V3z + Ac = U3
Ax*Nx + Ay*Ny + Az*Nz = 0

Bx*V1x + By*V1y + Bz*V1z + Bc = V1
Bx*V2x + By*V2y + Bz*V2z + Bc = V2
Bx*V3x + By*V3y + Bz*V3z + Bc = V3
Bx*Nx + By*Ny + Bz*Nz = 0

These are now fully determined systems, that only go denormal when the mapping is denormal.
Back to top
View user's profile Send private message
TenTerHooK
Member


Joined: 28 Mar 2007
Posts: 12

PostPosted: Tue Aug 14, 2007 12:32 am    Post subject: Reply with quote

Does that help with fixing the bad mapping in Torque?

..or is that theoretical..

..sorry.. me no program good.. me program bad.. :/
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DeleD Community Edition Forum Index -> DeleD Community Edition All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum