0

I'm making a skybox and between each textures there is a very tiny white line, the coordinates of vertex & textures seems to be ok (it's only 1 and -1 so I don't see any way I could have failed there).

Any way to solve this ?

genpfault
  • 51,148
  • 11
  • 85
  • 139
IggY
  • 3,005
  • 4
  • 29
  • 54

1 Answers1

3

TL;DR: Trivial solution: Use a cubemap texture instead.

Explanation:

(it's only 1 and -1 so I don't see any way I could have failed there)

Well, the texture coordinates -1 and 1, don't fall onto pixels centers. It's basically a fencepost problem, I explained it here

https://stackoverflow.com/a/5879551/524368

Note that in the case of a skybox the problem is trivially avoided, by not using 6 different textures on six separately drawn quads, but instead using a cube map texture, where are six sides are contained within one contiguous image in a sphere like topology.

Community
  • 1
  • 1
datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • I've heard there is a way to force openGL to display the last pixel line of the texture instead of drawing a white line, but I can't find this function :s I'd prefer to find this kind of solution than changing the way I print my texture (too much changes... :s) – IggY Oct 04 '12 at 16:50
  • 1
    @IggY Yes, it means setting the wrapping mode appropriately: `glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)` and likewise for the t-coordinate. Though this will probably interfere with your texCoords going from -1 to 1 and you will have to change them to go from 0 to 1. But what *datenwolf* said is still the best solution in this particular case (and probably also faster than 5 drawcalls with 5 different textures bound in between). – Christian Rau Oct 04 '12 at 19:12
  • glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) was exactly what I was looking for, thank you :) i know that cubemap should be the best solution to draw...a cubemap but i'm really noob in openGL and I didn't mnaged to do it this way, and now that my cube is drawed as I want...I don't really feel like changing it :) – IggY Oct 05 '12 at 09:39
  • @IggY As a general rule you should always set all the parameters you need special values for, like the wrapping and filtering modes, and not count on any default values. – Christian Rau Oct 05 '12 at 13:20