Ok, so I'm loading an animated bitmap using D3DXCreateTextureFromFileEx and creating a sprite that will use the texture. The bitmap is 48x48 and split into 4 frames of 24x24.
Note: I load the texture with filters (D3DX_FILTER_MIRROR || D3DX_FILTER_NONE).
Now when I draw a frame from the texture using the sprite and the required source RECT, I'm getting some 'bleeding' (right word?) from the other frames (At the edge of the sprite I can see pixels from the other frames).
I understand that I wouldn't get this if the bitmap wasn't split into frames because D3DX_FILTER_MIRROR doesn't wrap the U-V coordinates. How can I get it so that it doesn't read from outside my source rect for that frame?
If I didn't explain that well then just let me know and I'll try harder :wacko:
Thanks in advance, :yes:
Animated sprite texture bleeding. (DX9, C++)
Started by poita, Apr 23 2006 09:14 AM
4 replies to this topic
#1
Posted 23 April 2006 - 09:14 AM
#2
Posted 23 April 2006 - 11:12 AM
Disable texture filtering and be careful with the texel sampling or a better way would be to leave few texel wide borders between frames. Remember to disable mipmapping as well.
#3
Posted 23 April 2006 - 02:26 PM
juhnu said:
Disable texture filtering and be careful with the texel sampling or a better way would be to leave few texel wide borders between frames. Remember to disable mipmapping as well.
Doesn't D3DX_FILTER_NONE disable texture filtering? And what do you mean by being careful with texel sampling? (I'm a bit new to programming with DirectX, not up with the lingo yet :) )
Yeah, leaving a border between frames would work, it's just that I would like a more 'elegant' way of doing it. :geek:
#4
Posted 23 April 2006 - 02:59 PM
poita said:
Doesn't D3DX_FILTER_NONE disable texture filtering? And what do you mean by being careful with texel sampling? (I'm a bit new to programming with DirectX, not up with the lingo yet :) )
Yeah, leaving a border between frames would work, it's just that I would like a more 'elegant' way of doing it. :geek:
Yeah, leaving a border between frames would work, it's just that I would like a more 'elegant' way of doing it. :geek:
I should have been more elaborate I think. With the texture filtering I meant the filtering which is done when a texel is sampled. It's a sampler state, which can be set using the method IDirect3DDevice9::SetSamplerState(). The filtering enum you give to the d3dx texture loading function has nothing to do with this, but affects how a texture is resampled loading time if needed(if you have forced a specific texture size or the mipmap generation.)
If you use a point filtering (taking the nearest texel) you could survive without making borders in theory, but I think it's not really worth the trouble.
Check this if you want to know better about the texture sampling rules:
http://www.paradoxal...nt_Sampling.htm
However, I would recommend you to use borders around sprites It's a common and tested way to solve this problem. Also sprites would probably look much better when you can use the bilinear filtering.
#5
Posted 23 April 2006 - 04:10 PM
Thanks a lot. I'll look into those. I'll probably get round to it tomorrow and post the results.
Thanks again
Thanks again
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












