views:

27

answers:

1

Hi,

I've been working on cross-platform 3D engine but atm I have version running natively on OSX and iPhone/iPad ( which in Simulator uses system GL library ). The problem I'm experiencing is that each texture is slightly shifted in both directions ( looks like just about one texel shift ) and I would look more in my code if I didn't see same issue in Blender3D - after generating some lightmaps it became more visible on color gradients. Texture files are ok and same texture coords ( which just covers whole quad ).

Here's an example of how it looks in blender ( tex coords for 2-triangles are for corners in range (0.0, 0.0)-(1.0, 1.0) ): http://i28.tinypic.com/2yllfr5.png

You can see there on the right and up edges of marked quad which are filled with wrong texels.

Any idea how to work around it? I use OSX 10.6, updated to the latest version.

Thanks! J

+3  A: 

Problem solved. For those who will find artefacts after texturing geometry on a texture edges the answer may be helpful. There are two reasons why this is happening:

  • GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_R are set default to GL_REPEAT
  • if you set GL_CLAMP on tex param then it will blend with a border outside texture area on quad edges ( which is black by default ).

Solution is simple, for GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T you have to use GL_CLAMP_TO_EDGE which clamps texture coords to 0.0+0.5 and 1.0-0.5 giving a margin of 0.5 texel on each side of texture.

I hope it'll help others who'll find similar problem.

Jsr