

In this case, you will always be sampling the center of each texel and you should not get any bleeding. In this example, these are the coordinates you want to use: What you should do instead is address the center of each texel. This is because you're addressing the borders between texels, and not the centers. The same will happen at u-coordinate 0, and the same for v-coordinates. You're probably getting the top-left quarter by using uv coordinates of (0,0) to (0.5, 0.5):Īnd the problem is that at u-coordinate 0.5, the sampler will interpolate the destination fragment using half of the left texel and half of the right texel. However, what I think is going on with your program right now is that you're probably not using the correct texture coordinates, and because of that your textures are bleeding.
Physicseditor on texture atlas skin#
Adding padding will simply move the problem to a lower mip level.Īs a rule of thumb, for 2D, which is where you usually do atlasing, you don't mipmap while for 3D, which is where you mipmap, you don't atlas (actually, you skin in such a way that bleeding won't be a problem)

In general, you don't want to naively mix atlasing with mipmapping, because unless all your subtextures are exactly 1x1 pixel sized, you will experience texture bleeding. Okay, I think you have two problems going on here. Sadly, for some reasons explained in the comments, I cannot change to different textures or texture arrays. How can I solve this texture bleeding? Since using a texture atlas is popular technique there might be a common approach. At far distances the stripes occur anyway. I also tried added an offset in the texture coordinates to pick a slightly smaller area of the tile but since the unwanted effect depends on the distance to the camera this cannot solve the problem completely. GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST) GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
Physicseditor on texture atlas full size#
That results in lines of wrong colors between cubes (you may need to view the screenshot below at its full size to see the graphical flaws):įor now I use these interpolation settings but I tried every combination and even GL_NEAREST without mipmapping doesn't provide better results. The problem is that the texture of distant cubes interpolates with adjacent tiles in the texture atlas. I generate a vertex buffer from the voxel data and use a texture atlas for looks of different blocks: In my game there is a Minecraft-like terrain made out of cubes.
