Skip to main content
gamedev.net
🔒 Locked

Texture problem

Started by no hit wonder Aug 4, 2006 at 5:06 PM 3 replies 350+ views
Original Post
no hit wonder
no hit wonder
I'm constructing a 2d game at the moment using directx, and am having a bit of an annoying problem with the textures being displayed on quads. This is a screen shot of the problem I'm facing. The floor is bright blue, and the things on either side are walls. The floor has been turned blue and the borders of the wall texture have been turned bright green for the sake of making it easier to see. I have no idea why this happens when the quad is tilted one direction, but not in the other, and I've double and triple checked my texture coordinates, and they are correct. The same coordinate generating methods are being used for the tiles on the ground, which never seem to show any sign of problems. The texture that is causing the problem is one of many on a texture sheet, and if the green wasn't there, it would be pulling whatever color was on the adjacent texture. The wall is actually drawn as a 64X32 pixel rectangle image. The sampler that is being used on the walls is the magnifier, and it is currently set to POINT [nearest texel used], but setting it to something else only makes the problem more obvious. Any clues on what exactly my options are on fixing this issue? shrink the texture coordinates by .5 toward the center of the quad to leave a buffer zone? Over draw the figures?... Also, any idea why this happens with the magnification filter? [i figured the minification filter would have this problem, but the magnification filter wouldn't since closest point should always be within the area i want.] Any additional info i can give that will help, feel free to ask and i'll do what i can to provide it quickly. I'm having another problem also, but I'll try to get this one fixed, and then the other :P oh, and hello everyone
Evil Steve
Evil Steve
Hi, welcome to GDNet [smile]

This sort of problem is usually caused by the walls and floor using different vertices, even if they're in the "same" place. The problem occurs due to precision issues on the graphics card.

If you use the exact same vertices for the walls and floor, the problem should disappear.
no hit wonder
no hit wonder
The floor is just there for contrast in this case, i can draw the wall all alone and it'll cause the same problem unfortunately. They use different textures, different vertices, and are for all practically purposes, completely independant [they aren't even in the same vertex buffer]. Consider the wall to be completely alone. [oh jeeze i hope i don't need to change THAT].

The problem is that it's sampling just over the border of where i told it to on the texture. The region is rectangular and axis aligned on the texture, so there should be no ambiguity with regard to drawing the texture, but it still manages to sample just outside of where i want it to : /

Should i try to combine the vertices even when the objects are totally independant?

Seems like getting it to sample specific texture regions is pretty tricky.

And thanks for the welcome
xycsoscyx
xycsoscyx
Even though you said you have point sampling enabled, it still sounds like bleeding from the texture. You said that it's all from one big texture (with multiple tiles on it), and the neighbor is green (and if you change it, it will pull THAT color). Especially when dealing with the perspective divide and such, the texture coordinates can get miffed a bit (because of precision issues, especially when dealing with coordinates like .05 to .1 kind of cases). Indenting them slightly (like you mentioned) could work.

That would probably be your first thing to try, and see how it works. You don't need to really indent much, only enough to offset and possible precision issues. You'll have to play with it a bit as there really isn't a perfect solution. Ultimately it shouldn't push in the correct sides any as long as the value is small enough (basically, you're trying to indent by less then a texel).
no hit wonder
no hit wonder
Tried indenting. First tried .5 texels, and it would cut off the right, left, and top edges by one pixel. Fiddled around with the numbers and got it to work pretty much exactly how i wanted with a value of .05 texels buffer. It seems so tiny a difference!

Incedently, my other problem that i illuded to earlier was animation frames picking up slices of neighboring frames, and this fix applied to them also, fixes both problems :D

I know it's a bandaid, and its not the right way to do it, and thus would still like to hear the 'correct' answer, but it's working, at least for now.

Thanks a bunch both of you for help.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.