**Articles list**:

- Cylinder UV Texture Mapping

**Cylinder UV Texture Mapping**:

Given that I did not find any good solutions to compute uv texture coordinates for a cylinder while searching on the Web (take a look at the bottom of this page as an example : http://paulbourke.net/texture_colour/texturemap/), I have decided to implement my own one.

**The U coordinate**is the same as a Sphere :

u = i / (float) (segments - 1);// where 'i' go from 0 to segments - 1

**The V coordinate**is the surface distance from the south pole to the current vertex divided by the total distance (surface distance from the south pole to the north pole) of the cylinder. The south pole is the disk center of the cylinder bottom cover (for a closed cylinder but you can adapt the surface distance trick for an open cylinder) and the north pole is the disk center of the cylinder top cover.

Thus the distance from south pole to the bottom of the cylinder is the

*bottom cover radius*, distance from bottom of the cylinder to the top of the cylinder is the

*cylinder length*, distance from the top of the cylinder to the north pole is the

*top cover radius*. We can now compute the V texture coordinate as below :

float total_distance = bottom_cover_radius + cylinder_length + top_cover_radius;

Disk center of the bottom cover :v = 0.0f;

Bottom of the cylinder :v = bottom_cover_radius / total_distance;

Top of the cylinder :v = (bottom_cover_radius + cylinder_length) / total_distance;

Disk center of the top cover :v = 1.0f;

**Results**: