PDA

View Full Version : Texture Mapping Eccentricities



steve_hiemstra
04-03-2003, 07:37 AM
Hi All,

I haven't done much Texture Mapping beyond the simple 'map to cube' demos, but I get the 'gist' of UV points and manipulations...

Still, I have doubts as to how I can map to 'irregular poly-surfaces' (let's assume that all poly-surfaces are defined in tri's, and are flat, for simplicity), so I thought I would pose a few 'what ifs' and see if anyone can help solve them:

1) What if - I have a concave poly, for example, a star. How would I map a single texture so it would 'fit' the star? Can I use a 'square' surrounding the star to define the UV points to map my texture to? Do I have to sub-divide my poly into convex pieces (and do the same to my texture)?

2) What if - I have to 'cut off' part of the texture? Let's say I have an object, and I 'lop off' the end of it. Now the texture extends beyond the remaining piece. Is there a way to 'truncate' my texture?

3) What if - I have transparent portions in my texture? How does the bitmap data need to be represented(what colors, maybe alpha data req'd?) for the transparent pixels? Do I need a transparency mask?

Keep in mind that I'm half way between beginner and expert, and I haven't the time to dig through all tutorials looking for answers to these questions (I'm on a schedule).

Thanks in Advance,

Steve

Won
04-03-2003, 09:47 AM
With all due respect, if you are asking these questions, you are much closer to beginner than expert. Unfortunately, a "gist" is usually not enough to do what you want.

As a general answer to your questions, I'll explain texture mapping:

OpenGL only renders convex polygons, usually triangles and sometimes quads. For simplicity, consider triangles only. Each vertex has a texture coordinate, and the texture coordinates for all the fragments generated by rasterizing the triangle will have texture coordinates created by interpolating along those vertices. This is essentially the same as when you interpolate vertex colors, although interpolating texture coordinates is usually perspective corrected whereas interpolating colors is not. In any case, texture coordinates index the currently bound texture. This means that your mapping from your geometry to your texture map is very flexible; each triangle can have its own set of texture coordinates.

1) You can define your texture any way you think is reasonable. You only need to subdivide your concave poly into convex polys.

2) A truncation happens automatically. If you don't have any texture coordinates addressing part of a texture, then it never gets drawn.

3)Transparency is usually represented in the alpha channel of a texture.

Good luck with your deadlines.

-Won

steve_hiemstra
04-03-2003, 10:01 AM
With all due respect - my status as a beginner or expert is not of importance here. Expertise comes and goes so swiftly where technology is concerned.

I appreciate your lending me assistance, and I understand your answers to 2) and 3).

Your answer to 1) leaves me hanging though. If you, or anyone else can elaborate I would much appreciate it.

Steve

Won
04-03-2003, 10:19 AM
For 1), I meant that you can define your texture mapping however you want. The mapping is defined by the texture coordinates you assign for each vertex. If you wanted your star to be a "cookie cutter" out of a texture pattern, then you can certainly do that by assigning texture coordinates for each vertex to correspond to their location on the texture. But texture mapping is much more flexible than that. Maybe if you describe exactly what you want to do, I can help you out more.

Sorry if I hurt your pride with that "all due respect" comment, but it was just a gentle way of telling you that you're asking a beginner's question.

-Won