Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XNA blurred sprites when scaled

Tags:

c#

xna

sprite

I have a 32x32 sprite for a pixel art based game but when I scale the sprite up, it becomes very blurred, I have read about online and I believe the solution lies somewhere in SamplerState.

I've had a look on the MSDN and around StackOverflow and Gamedev but found nothing useful to a beginner like me. A few code sample but I have no idea where I could work them into my project.

I'm not providing any of my code yet since I'm sure it isn't of any use. All I want is someone to explain how or even just throw some simpler code at me. I don't mind which, most likely I would like to have it explained becuase then I would know how to do it in the future.

like image 884
Pyroglyph Avatar asked Dec 20 '22 12:12

Pyroglyph


1 Answers

SpriteBatch.Begin can take a SamplerState parameter. All you do is pass in SamplerState.PointClamp

SpriteBatch.Begin (SpriteSortMode, BlendState, SamplerState.PointClamp, DepthStencilState, RasterizerState)

Just like that but replace SpriteSortMode, BlendState, DepthStencilState, and RasterizerState with your desired values. Some can take null if you do not wish to use it.

like image 113
PaulBinder Avatar answered Dec 30 '22 12:12

PaulBinder