Skip to main content
GameDev.net gamedev.net
🔒 Locked

White border while sampling zoomed textures with directX

Started by arrecio Jul 21, 2012 at 9:30 AM 3 replies 1.6k views
Original Post
arrecio
arrecio
hi,

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

badez.png

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);
Device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
Device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
Device->SetSamplerState(0, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP);

in directX

thnx in advance

[SOLVED]

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.
eppo
eppo
I think this article best describes the problem you're dealing with:

http://blogs.msdn.co...ha-cutouts.aspx

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.
arrecio
arrecio
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.
arrecio
arrecio

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

http://blogs.msdn.co...studio-4-0.aspx


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.

Topic Locked

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

Sign in to reply to this topic.