How to put texture on a sphere in DirectX 9.0

dule

Newcomer
Hi!

I'm trying to make a 3D smiley in directX and I just can't figure how to put some texture on a sphere. I've tried lots of things (making .x file from a sphere, I've read an article about Spherical texture mapping etc.)

If someone knows the solution, please help.

thx

Dule
 
If you are trying to map a plain 2d texture map onto a sphere, you will get trouble with distortion and singularities (points where the texture map squeezes together by an infinite amount along at least one texture axis, causing various rendering artifacts; it's a bit like trying to find the north pole on a world map). You will probably get better results by using a cube map, if you can make one - place the origin of the sphere's coordinate system at the center of the sphere, then set texture coordinates = vertex coordinates for every vertex on the sphere.
 
For plain 2D->3D, there are some suggestions in Watt & Watt's "Advanced Animation and Rendering Techniques".

For example, for the 2D->sphere you can distort your mapping so that each texel always maps to the same amount of area on the sphere.
 
I'd have thought that if he's trying to create a smiley.

He might aswell just go with a simple 2D planar projection. He doesn't exactly need optimal usage of his texture space, and a bit of stretching at the edges isn't going to hurt if it's all mono colored :)
 
Back
Top