Overlapping in textures
BlitzMax Forums/MiniB3D Module/Overlapping in textures
| ||
I am having problems with textures. When I have more than one texture in an image, they get overlapped by the renderer. What I think is happening, is that the texture is getting aliased before being applied to the mesh causing nearby textures to bleed into each other. Here is an example: This image contains 2 textures. ![]() Notice that the two faces do not overlap. I can draw a selection rectangle around either face without including any of the other. Here is some test code And this is the result. Notice the pixels pointed to by the yellow arrows. ![]() At first, I thought maybe the uv offsets were off by one pixel. But if you change the cls color to a contrasting color, say 128,128,128, then you can plainly see that the textures line up with the edge of the graphics. I have tried other textures as well. Some overlap so bad, that even if I use a 1 pixel border around each texture, there is still bleeding between them. As I understand it, using a flag of 1 in the LoadTexture command should display the texture as-is, without any aliasing. But there seems to be aliasing done to the image anyway. |
| ||
Blitz3D does the exact same thing (I converted your code and checked). It's because of the bilinear filtering, which smoothes out every pixel with adjacent pixel values. Unlike Blitz3D you can turn it off though. You just need to edit TMesh.Update, specifically this part: ' mipmapping texture flag If tex_flags&8<>0 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR) Else glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR) EndIf Change GL_LINEAR in the bottom two lines to GL_NEAREST. This will remove the bleeding but make your textures more blocky. |
| ||
Or do as I usually do, put some space between them. Move them a bit apart. Might not be possible sometimes, but I cannot see why it would not work just fine in this example. |
| ||
Thanks. I guess I'll see if I can figure out a way to get deps suggestion working. I'm trying to get a bitmap font to work, and the font pakage defaults to having all the charaters spaced right next to each other. There is an option to add space around them, but it is mainly for post processing effects and it adds the spacing to the metrics. So I need to compensate for this. |