0
\$\begingroup\$

I've debugged my application with codeXL and can verify that my texture is getting these attributes applied:

GL_TEXTURE_MIN_FILTER: GL_LINEAR
GL_TEXTURE_MAG_FILTER: GL_LINEAR
GL_TEXTURE_WRAP_S: GL_CLAMP_TO_EDGE
GL_TEXTURE_WRAP_T: GL_CLAMP_TO_EDGE
GL_TEXTURE_WRAP_R: GL_CLAMP_TO_EDGE

With the following UV data:

0, 0,
1, 0,
1, 1,
1, 1,
0, 1,
0, 0,
0, 0,
1, 0,
1, 1,
1, 1,
0, 1,
0, 0,
0, 1,
0, 1,
0, 0,
0, 0,
0, 0,
0, 1,
1, 1,
1, 1,
1, 0,
1, 0,
1, 0,
1, 1,
0, 0,
1, 0,
1, 0,
1, 0,
0, 0,
0, 0,
0, 1,
1, 1,
1, 1,
1, 1,
0, 1,
0, 1

Yet my cube still looks like this: http://imgur.com/Dj2hCkp

The Front and Back are being mapped fine, but the sides and top/bot are all stretched. I've tried with GL_REPEAT, GL_CLAMP_TO_EDGE/BORDER, GL_MIRRORED_REPEAT, it's all the same result. I've tried only doing it with S and T. At this point I'm not sure what the problem is.

Vertex Shader + fragment + Buffers: (It's not that long)

https://ideone.com/5U39M3

I'm not really sure what it could be at this point. I thought my texture wasn't getting it's attributes applied correctly, but it is. Then i thought it was just my wrapping method, but all methods lead to the same result.

\$\endgroup\$
  • \$\begingroup\$ My crystal ball tells me that your UV coordinates for vertices are incorrect or used incorrectly. \$\endgroup\$ – HolyBlackCat Jun 12 '16 at 20:27
  • \$\begingroup\$ I calculate them by clamping the x,y vertices position to 0-1 by doing UV = vec2((Position.x + 1.0) / 2.0 ), (Position.y + 1.0) / 2.0); so they should be right. \$\endgroup\$ – Omar Martinez Jun 12 '16 at 20:29
  • \$\begingroup\$ Nope. You don't take Z into account. \$\endgroup\$ – HolyBlackCat Jun 12 '16 at 20:53
  • \$\begingroup\$ I'm using the same texture on all sides, so I didn't think I needed the z coordinator. Glsl won't let me pass in a texture(sampler2DTexture, textureCoords); sampler2D needs a vec2 as Texpositions. \$\endgroup\$ – Omar Martinez Jun 12 '16 at 21:21
  • \$\begingroup\$ I'm pretty sure that texture coordinates are incorrect. Instead of computing them you can try to specify them manually. (I think there is no way of computing texture coordinate for a point based only on it's position.) \$\endgroup\$ – HolyBlackCat Jun 12 '16 at 21:56
-1
\$\begingroup\$

So turns out it was a problem with my UV coordinates.

\$\endgroup\$
  • 2
    \$\begingroup\$ Can you explain what the problem with the UV coordinates was? It's always nice to see an example so when I make the exact same mistake, I can see the solution! \$\endgroup\$ – user1118321 Jun 13 '16 at 2:37
  • \$\begingroup\$ I wasn't clamping the values properly. It's just copied the UV's online for a cube and it works fine now. I just wanted to create a function that would do it, instead of me having to write them all out. \$\endgroup\$ – Omar Martinez Jun 13 '16 at 4:35
  • \$\begingroup\$ @OmarMartinez Could you edit your answer and put that in? \$\endgroup\$ – Vaillancourt Jun 13 '16 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.