Can someone correct my texture Coordinates?

Started by coolian, September 14, 2020, 09:18:15

Previous topic - Next topic

coolian

//                  positions           //colours          textureCoords
			-0.5f, -0.5f, -0.5f,  1.0f, 0.0f, 0.0f,  0.0f, 0.0f,
			 0.5f, -0.5f, -0.5f,  0.0f, 1.0f, 0.0f,  1.0f, 0.0f,
			 0.5f,  0.5f, -0.5f,  0.0f, 0.0f, 1.0f,  1.0f, 1.0f,
			-0.5f,  0.5f, -0.5f,  1.0f, 1.0f, 0.0f,  0.0f, 1.0f,
			-0.5f, -0.5f,  0.5f,  1.0f, 0.0f, 0.0f,  0.0f, 0.0f,
			 0.5f, -0.5f,  0.5f,  0.0f, 1.0f, 0.0f,  1.0f, 0.0f,
			 0.5f,  0.5f,  0.5f,  0.0f, 0.0f, 1.0f,  1.0f, 1.0f,
			-0.5f,  0.5f,  0.5f,  1.0f, 1.0f, 0.0f,  0.0f, 1.0f

//              indices
		    0, 1, 3, 3, 1, 2,
		    1, 5, 2, 2, 5, 6,
		    5, 4, 6, 6, 4, 7,
		    4, 0, 7, 7, 0, 3,
		    3, 2, 7, 7, 2, 6,
		    4, 5, 0, 0, 5, 1

the face facing up shows the correct texture but no other visible face does

KaiHH

If this is supposed to be a textured cube, then you cannot share all 8 vertices with their texture coordinates. Each vertex is currently shared by three faces, but needs different texture coordinates based on where on those respective three faces it is located at.

coolian

Quote from: KaiHH on September 14, 2020, 10:54:28
If this is supposed to be a textured cube, then you cannot share all 8 vertices with their texture coordinates. Each vertex is currently shared by three faces, but needs different texture coordinates based on where on those respective three faces it is located at.

So i need more than 8 texture coords but then how are they supposed to be and how do i figure out which texture coordinates to use?

KaiHH

No. You need to have 24 (= 4*6, 4 vertices per quad, 6 quads) vertices, because you can only share the four vertices among the two triangles of each of the six faces of the cube.