0
\$\begingroup\$

I have a pretty vanilla Monogame game. I'm using PNG for all my sprites (made in Photoshop). I noticed that XNA is butchering the aliasing; no matter what I do, my graphics appear jaggedy.

Below is a screenshot. The bottom half is what XNA shows me when I zoom in 2X using a Matrix on my GraphicsDevice (to make the effect more obvious). The top is when I pasted the same sprites from Photoshop and scaled them to 200%.

Note that partially transparent pixels are turning whiteish.

Is there a way to fix this? What am I doing wrong?

Here's the relevant call to draw to the SpriteBatch:

spriteBatch.Draw(this.texture, this.positionVector, null, Color.White, this.Angle, this.originVector, 1f, SpriteEffects.None, 0f);

(this.positionVector can easily be Vector.Zero; Color.White as 100% alpha, I think; this.Angle can be a real angle (small > in the image) or zero (the orb itself).

enter image description here

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

Ensure you're enabling blending in your SpriteBatch.Begin() call. I think for PNGs, BlendState.NonPremultiplied is probably the one you want.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Its depends if the file is being loaded though the content processor or not. If it is BlendState.AphaBlend is the one he wants as by default the processor will pre-multiplies the alpha for you irregardless of the file type. \$\endgroup\$ Nov 29, 2012 at 22:14
  • \$\begingroup\$ Please see my related question about how to add content. I'm not currently using the XNA content pipeline. \$\endgroup\$
    – ashes999
    Nov 29, 2012 at 22:21
  • \$\begingroup\$ @ashes999 Well, you'll need to use the right blend mode for however you're getting the image into your engine. \$\endgroup\$ Nov 29, 2012 at 22:27
  • \$\begingroup\$ @NathanReed NonPreMulitplied for the win. Is it possible you can also attempt to answer my other question? :) gamedev.stackexchange.com/questions/44599/… \$\endgroup\$
    – ashes999
    Nov 30, 2012 at 11:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .