View Full Version : Mapping triangle to a right angle triangle
enigma
04-23-2008, 06:38 AM
I open this topic to speak about a texture map representation method.
Each triangle is mapped to a right angle triangle and these are packed together in arbitrary positions with a few pixels of padding between the triangles.
So, for example, if the model is a cube, this can be her texture map:
http://img504.imageshack.us/img504/5277/senzatitolo1it7.jpg (http://imageshack.us)
First, simple case. If the model is a cube, the mapping is already done... But how can i render each triangle to a plane? I would obtain an image similar to the precedent.
Thanks!
Wernaeh
04-23-2008, 03:11 PM
What exactly do you have in mind ?
Do you wish to render the given triangles to some texture (i.e. software / hardware rasterization) or do you want to render the outlines only ?
Basically, if you just want to fill a plane with triangle outlines, you don't even need to know the original triangles, it is enough to know how many there are, then you can determine how many rows and columns of target right-angled triangles to render.
In the former case, things get a little more difficult. One alternative would be to just run through all your triangles, and keep texture coordinates, while rebuilding vertex coords so that they are appropriately positioned on the projection plane.
Cheers,
- Wernaeh
TheNut
04-23-2008, 06:51 PM
If I understand this correctly, you want to unwrap your model. It's quite simple really, just read in the UVs for each point in the triangle and draw the outline of the triangle at those coordinates on the plane. Since UV space is capped [0,1], you will want to scale it out to something like [0,256] to fit the result on a 256x256 image, or whatever aspect ratio you want.
BTW, for a cube you will want to use a "Cube" (sometimes called "Box") map as opposed to the one you presented. Having gaps between triangles like that will produce disastrous quality, especially with any texture filtering.
enigma
04-24-2008, 06:45 AM
What exactly do you have in mind ?
I must generating a texture map, with the method I've presented.
First I must arrange triangles in a simplifiled mesh onto a plane, and then create a texture map from this arrangement.
In the first simple case, if the model is a cube, I have already right triangles so I only must arrange trianles. But how?
Wernaeh
04-24-2008, 07:38 AM
Just to make this clear:
You already have a completely texture mapped object (i.e. each triangle already has a texture properly applied to it, including UV coordinates)
Now, you want to create a texture map from this object which displays the texture part of each original triangle on a right-angled one ?
Cheers,
- Wernaeh
enigma
04-24-2008, 08:12 AM
You already have a completely texture mapped object (i.e. each triangle already has a texture properly applied to it, including UV coordinates)
No, I only have a flat shaded model.
Starting from this model, I want generate a texture map.
Wernaeh
04-24-2008, 09:07 AM
Ah so you just have the model, and want to create a texture atlas from that ?
I.e. you want to generate both UV coordinates and a output texture so that later on an artist may paint that texture and you have a texture map to apply ?
In that case, I'd harshly suggest against your approach - as TheNut said above, this will give poor quality - especially if considering texture filtering. Also, usually you'd want to maintain a constant texture-space to world-space ratio (for example a triangle that is 4x2 world space units might get a 16x4 pixel texture map, while a triangle with 8x9 world space units then should have a 32x36 pixel texture). Otherwise, there will be quite visible stretching over the triangles. Finally, the artist who later on should paint onto these triangles will curse you for the fact that he has to find out where each triangle actually is on the model.
If you want to have automatical unwrapping, you need some sort of more clever algorithm which takes many other factors into account, and you can't restrict yourself on right-angled, equally-sized triangles.
Alternatives include manual or pseudo-manual unwrapping (as offered by most modelling packages these days) or investing in some proper automated unwrapper (most 3D painting tools come with one these days).
Finally, if this should be done for lightmapping an existing mesh, there also are specialized alternative algorithms you should consider.
Hope this helps,
Cheers,
- Wernaeh
enigma
04-24-2008, 09:32 AM
I.e. you want to generate both UV coordinates and a output texture so that later on an artist may paint that texture and you have a texture map to apply ?
It's correct, but without any artists.
Will try to explain better. I'm working on my thesis.
I load a model, for example the teapot, and I must take some picture of this model with different parameters, for example different light, different color, or different material.
In the second step I must texture my model with this pictures, so I get some problems, one of these, is the visible seams.
In the third step I work on this pictures (image filtering, blending, ...).
The goal is texture the model with this pictures, after the pictures treatment to avoid the problems.
The texture representation that I must implement, is that I have described. And the pictures are my texture.
So there aren't any artists, or modelling packages, I must implement all that.
It's more clear?
Thanks!
Reedbeta
04-24-2008, 11:41 AM
It sounds to me like what you are doing is related to lightmapping. You might want to investigate texture packing algorithms for that as Wernaeh suggested, as they might be suitable for your project. If you google for lightmapping you will find a fair amount of info.
vBulletin, Copyright ©2000-2010, Jelsoft Enterprises Ltd.