LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: coolian on September 14, 2020, 09:18:15

Title: Can someone correct my texture Coordinates?
Post by: coolian on September 14, 2020, 09:18:15
Code: [Select]
//                  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
Code: [Select]
//              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
Title: Re: Can someone correct my texture Coordinates?
Post by: 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.
Title: Re: Can someone correct my texture Coordinates?
Post by: coolian on September 14, 2020, 11:08:11
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?
Title: Re: Can someone correct my texture Coordinates?
Post by: KaiHH on September 14, 2020, 11:08:47
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.