Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
1  
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. –  ClassicThunder Nov 29 '12 at 22:14
    
Please see my related question about how to add content. I'm not currently using the XNA content pipeline. –  ashes999 Nov 29 '12 at 22:21
    
@ashes999 Well, you'll need to use the right blend mode for however you're getting the image into your engine. –  Nathan Reed Nov 29 '12 at 22:27
    
@NathanReed NonPreMulitplied for the win. Is it possible you can also attempt to answer my other question? :) gamedev.stackexchange.com/questions/44599/… –  ashes999 Nov 30 '12 at 11:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.