Jump to content
  • Advertisement
Sign in to follow this  

DirectX sprites have white outline

This topic is 2223 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

I'm using DirectX to import .png images (with transparency) as textures and then applying those to a rectangular vertex group with a Draw call for each sprite at render time via the pixel shader sampling the texture resources, and using a transformation matrix passed to the vertex shader to position and rotate them properly
They can be rotated but not scaled, and are drawn on top of background
Some of the time, for some of the sprites, in some areas, there appears a white outline
Typically, only the sprites with dimensions greater than 20x20 pixels have this issue, and it is especially noticeable in interior areas with 0 opacity
Any ideas as to why this occurring or how to fix it?

Share this post


Link to post
Share on other sites
Advertisement
What are your sampler settings? Whats probably happening is when the image is being sampled, the pixels are being "blended" together in a way, so that the image doesn't appear all pixelated when it's stretched out. the transparent parts around the colored parts are probably being blended together, so the alpha is no longer exactly zero. in your pixel shader, you could try to just clip any pixels who's alpha value is less than 0.25. that usually seems to work pretty well. just include this in your pixel shader after you sample the texture for the current pixel:

clip(finalColor.a - 0.25);

where finalColor is the color you sampled from the texture

Share this post


Link to post
Share on other sites
You were correct, the sampler had a linear filter setting instead of a point filter
I changed it such that it doesn't do any type of blending, or at least to the point at which it doesn't create those white borders
Thank you so much, again. You are awesome!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!