Strange behaviour with texture mapping

Started by
10 comments, last by unbird 10 years, 11 months ago

If I stick with the BasicEffect I don't think I'll be able to fix it, however I am going to be writing a replacement shader so taking Hodgman's insight into mind it should sort things out. Will report back with an update.

As for VertexPositionNormalTexture not supporting the W component - you can easily create your own vertex declaration that does include it. Have you tried this?

Alternately, why can't you perform your transformations on the GPU instead of on the CPU (or maybe in addition to on the CPU, if you require the projected coordinates for calculations in your code). Then you wouldn't run into this problem.

Advertisement
You unlikely get rid of those artifacts on such a low tesselated sphere. The faces are trapezoids which - as you've seen yourself in the 2D case - don't map niceley to rectangular tex-coords.

You could UV unwrap your sphere like in the following picture, but then you still have the problem of painting said texture.

f16f1c255519575.jpg

The 2D problem turns up regularly here and elsewhere. There are two solutions: One is a bilinear inverse, the other is the perspective approach. The former is more involved, for the latter one can (ab)use the graphics hardware.

I once found the solution myself using a bit a convoluted approach here. More elegantly one can use homogenous 2D coords, derived here by (of course) Alvaro. IIRC this is the same approach Blinn showed in his Notation3 book.

I think this is also possible for 3D. Since this is a sphere (all faces are symmetric trapezoids) it will likely simplify the calculation.

Edit: Proof of concept.

This topic is closed to new replies.

Advertisement