SOLVED LWJGL - Textured quad artifact*

I’m creating a “tiled” 3D world. And I have a tearing issue between each tile. BUT only if I a certain way?

I am filtering with GL_NEAREST, no mipmapping, and I am clamping to edge.

Any tips?

here for reference:

Can’t remember what that is called but whatever your vsync setting is, reverse it. That might solve the issue, it’s done sort of tearing problem I think.

Edit: hit me, never seen you mention it is tearing :stuck_out_tongue:

looks like it’s mesh related. … do the triangles sharing an edge share the same vertices (same element ID) ?

Well I guess its not tearing. More like artifact. Like an edge that isn’t AAed.

@basil_ each tile is a separate quad. only verts being shared is between the 2 triangle that make each quad

And I figured out what it is, but I don’t know a fix for it.

It only does this when the texture REGION I select fo the tiles has a white edge

For example, if i go for region (0, 0, 32, 32) and the bottom of that region in the texture is blank it will come out white. If i get the region (0, 0, 32, 31) is fine.

I figure it’s a interpolation with filtering issue but I’m using nearest filtering on the tile texture.

aah i see. edge-clamping would not help then if i understand you correctly. you use a texture-atlas right ?

in that case - simulated edge clamping in the shader would help. texture-coords at the upper bound edges are rounding towards the next pixel. for a dirty fix, when you compute the texture coords, try limiting them to 0.0 - 0.99.

That’s a good idea. I’ll try that out

When i had this problem, i placed block texture region side by side in my PNG.
I guess it would be a good idea in general, to have a transparent offset between each block texture region in the texture.
That fixed it for me, when i used the texture atlas without offset between each region, even with GL_NEAREST it showed these edges at times.
Maybe try offset in your texture between regions in general, a few pixels should suffice.

I guess your texture coordinates are precise enough =) ?

oh, you’re right JJ.

shouldn’t we offset texture-coords by half a texel to fetch at texel-center instead of corner … when using nearest-filtering ?

Yeah that was the issue. I figured it out awhile ago. Thanks!

To be blatantly honest, i don’t know how exactly OpenGL handles the texture coordinates when using GL_NEAREST.
I had this problem when i made a voxel engine, and calculated my texture coordinates this way:
I made a custom class for texture coordinates, which is basically a float array with some other functionality.(So that i could enter the texCoords in Pixels)
TexCoord = (1.0f/Texture width or height)*pixels on texture

I guess there is a trick like that, but i don’t know, OpenGL tech wise :slight_smile:

[quote]Quote by KudoDEV
Yeah that was the issue. I figured it out awhile ago. Thanks!
[/quote]
What was the issue you found to be the problem?
The texture coordinates offset,or a texture related problem?

It was the precision of the tex coords :wink:

Thank you, couldn’t quite read it out of the thread :stuck_out_tongue:
May have missed it, but then, multiple times :-X

Greetings and all the best, JJ