Texture mapping
|
TextureMapping.png
Texture mapping is a method of adding realism to a computer-generated graphic. An image (the texture) is added (mapped) to a simpler shape that is generated in the scene, like a decal pasted to a flat surface. This reduces the amount of computing needed to create the shapes and textures in the scene. For instance, a sphere may be generated and a face texture mapped, to remove the need for processing the shape of the nose and eyes.
As graphics cards become more powerful, in theory texture mapping becomes less necessary and 3D rendering becomes more commonplace. In practice, however, the trend has recently been towards larger and more varied texture images, together with increasingly sophisticated ways to combine multiple textures for different aspects of the same object. (This is more significant in realtime graphics, where the number of textures that may be displayed simultaneously is a function of the available graphics memory.)
The way the resulting pixels on the screen are calculated from the texels (pixels of a texture), is governed by texture filtering. The fastest method is to use exactly one texel for every pixel, but more sophisticated techniques exist.
The following is Java code and should work.
public double[] SphereMap(double x, double y, double z, int radius) { /* x,y,z are normals of the sphere intersect multiplied by its radius */ /* i.e. vec3( intersect_pointv3-sphere_centre_pointv3) */ double u, v; v = ( Math.acos(z/radius) / PI ); if (y > 0.0){ u = ( Math.acos(x/(radius * Math.sin(PI *(v)))) / PI*2 ); }else{ u = ( (PI + Math.acos(x/(radius * Math.sin(PI *(v))))) / PI*2 ); } double myarray[] = { u, v }; return myarray; }
See also
External links
- Graphics for the Masses by Paul Rademacher (http://www.cs.unc.edu/~rademach/xroads-RT/RTarticle.html)
- High resolution textures resource (http://www.mayang.com/textures/)
- High resolution images and textures resource (http://www.imageafter.com/)
- Texture Hound | Utlimate 3d Texture Links Directory (http://www.texturehound.com/)