I wrote an algorithm that generates an icosahedron (20 faces, 12 vertices). Next, applying the bisection method to each triangle the necessary number of times, I get the scope of the desired "quality". If you feed this model to a simple shader, then you can see a quality round ball. The problems started when I assigned texture coordinates to each vertex and started sampling.

I told about the sphere so that there were no "why" and "why" questions, and there is a problem even if I wrap the icosahedron in texture, so for simplicity I will return to this figure.

A texture is a rectangle, if the icosahedron is wrapped with this rectangle, then there will be some kind of conditional line between the beginning and the end of the texture rectangle. The line of this joint will pass through some triangles of the icosahedron. I can not understand which texture coordinates to set the vertices of such a triangle. We cannot “shift” the texture coordinates of these vertices to the beginning of the texture or to the end, since other triangles are built on these vertices and everything is fine with them.

I see two solutions.

  1. The first is to change the method of generating the ball so that our vertices on the ball form arcs to which I can bind the interface line of the texture

  2. The second is to split the triangles at the junction line into other triangles so that the vertices are clearly on the junction line, they have the same world coordinates, but different texture coordinates.

Which method is better?

    1 answer 1

    There is a third, much more correct method:

    You need to turn on "repeat" textures when you go beyond the UV 0..1 range.

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // Ось U glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // Ось V 

    There are 4 basic types of replay, you need GL_REPEAT on the U axis.

    enter image description here

    And accordingly to make razvetku by type

    enter image description here

    Do not forget to make a gap in the polygons on the gap on the UV, so that there is no "accordion" at the junction.

    enter image description here

    • It is in the repetition mode that I impose a texture, I cannot figure out how to make a gap in the polygons, I observe exactly such an accordion =) - Alexei
    • I understand that you advise you to do this: in the picture where you gave the sweep example, if, for example, you take the first and last vertices of the top row, then they have world coordinates, but the first one will have a u-coordinate slightly higher than zero, and the last one more than one? - Alexei
    • @Alexei is true. The world coordinates and the normals should coincide (and everything else except UV) - Kromster