PDA

View Full Version : Texture mapping artefacts.



chronozphere
04-02-2007, 11:08 AM
Hi there. 8)

At the moment, i'm polishing my Texture-mapping routines.
And i ran into a few problems.

http://www.techzine.nl/f/g/36261phptOHaGc.jpg
http://www.techzine.nl/f/g/36261phpe0JVUG.jpg
http://www.techzine.nl/f/g/36261phpZYaTlG.jpg

{hope the images have acceptable sizes:) }

As you see, the cube looks fine but the sphere, cylinder and the cone have some artefacts at the top and the bottom. :(

I think i know why:
I want to map the texture to a sphere like a worldmap is mapped onto earth. This is all possible but i'll end up with one problem.
The top and bottom vertices (north-pole and south-pole) repersent the top and bottom edge of the worldmap/texture.
So basicly, a whole edge must be wrapped to one point.
So i cannot specify good texture coordinates for these two because the U coordinates should have a range from 0,0 to 1.0.

This way i'll end up with some weird artefacts at the top and bottom of all sphere/cylinder like geometries.

Moreover.. the bottom of the cone doesn't look to good either. :(
I've googled but i didn't find much info on Texture-mapping.

Does anyone have a sollution??

Any help would be greatly appreciated.

Nitrogen
04-02-2007, 01:30 PM
Your edges are mapped like this:



0.8------0.9------1.0-------0---
| | | |
| B | C | A |
| | | |


They should be mapped like this:



0.8------0.9------1 0-------0.1---
| | | | |
| B | C | | A |
| | | | |


Where A is your first quad/triangle in the strip, and B & C are the last triangles in the strip which wrap around and meet A again.

In the second diagram, the end of triangle C and the beginning of triangle A are separate, but they overlap (they are separated in the pic for clarity) there are two vertexes right on top of each other with the same position values, but different texcoord values for each corner of the quad.

Secondly, a texture coordinate can have any value you want, it's not restricted to 0.0 to 1.0.

Thirdly, your question about the world map projected onto a sphere. You CAN have all the texture coordinates mapped onto the north and south pole, you just have many vertexes all situated at the north pole, each with a different tex coord, and then link triangles to each one of these vertexes.

chronozphere
04-02-2007, 03:35 PM
I dont think that is the problem.




0.8------0.9------1.0-------0---
| | | | |
| X | Y | Z | A | B
| | | | |


In this case the whole texture is rendered from 0.0 to 1.0 (from A to Y).
The texture is rendered again (the Z part) but mirrored and cropped. 'A' lies on the cylinder surface and as you see... the surface is rendered correctly. The top/bottom fans are the problem (north/south pole problem).



Thirdly, your question about the world map projected onto a sphere. You CAN have all the texture coordinates mapped onto the north and south pole, you just have many vertexes all situated at the north pole, each with a different tex coord, and then link triangles to each one of these vertexes.


This sollution will change the ammount of vertices.
When i dont want a textured cylinder, then it's a (small) waste of processing time. So this sollution isn't very elegant.
Is this realy the only sollution??

A cube also has such problem. When i want to texture it.. i would rather use 6 detached quads (24 vertices) instead of 8 vertices.
And i guess there are more geometries that need extra vertices for proper texture mapping. :)

Are there other sollutions??
I would also like to hear how you guys textured your (computational) geometries. Doesn't matter what kind of geometry.. just the basic ones ;)