Jump to content
  • Advertisement
Sign in to follow this  

White border while sampling zoomed textures with directX

This topic is 2190 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


Im currently porting a work from XNA to DirectX using c++. Im stucked with a texture sampling issue.


There are 3 sprites in the image, original (1:1), XNA sampled (1:1.2) and directX sampled (1:1.2). Im getting a non desired white border in direct X.

Im using LinearClamp in XNA and

Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
Device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);

in directX

thnx in advance


Seems like XNA content processor sets alpha colors to TransparentBlack, my png has trasnparency over TransparentWhite so the sampler was doing the same but from 2 different sources. Edited by arrecio

Share this post

Link to post
Share on other sites
I think this article best describes the problem you're dealing with:


When bilinearly filtering, RGB values of texels with zero alpha, even though they are fully transparent, still influence interpolated color values.

As the article recommends, the best thing to counteract this, is to set the color value of these texels to the value of their nearest 'alpha > 0'-texel. Edited by eppo

Share this post

Link to post
Share on other sites
umn I thought I understood it,

So its possible the difference between my XNA code and my dx code results is becouse the content importer in XNA? what is doing some changes on my alpha texels?, in XNA im using content importer and in DX the CreateTextureFromFile method from a png file. Its strange, im taking two different results with (i think) same sampler and blender states on the device. Well thanx eppo, i will work on it.

Share this post

Link to post
Share on other sites

I believe the reason you don't see the issue in XNA is because it uses premultiplied alpha by default.


Yes, by default, but im using this call with SpriteBatch:

SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, null, null, null, null, matrix);

But u are right, PremultiplyAlpha is turn on for content processor, if i turn off it i get same results, mistery solved.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!