Friday, April 10, 2015

c# - How do I disable texture filtering for sprite scaling in XNA 4.0?


I have a sprite that I'm trying to scale up in XNA, but XNA is applying some sort of texture filtering that smooths it and makes it look ugly. I'd like it to just do pixel doubling instead of interpolation. How would I accomplish that?



Answer



You need to set the sampler state. The default for SpriteBatch is SamplerState.LinearClamp (ie: linear interpolation - the smooth/blurry one).


Choose one of the SpriteBatch.Begin calls that takes a SamplerState and pass in SamplerState.PointClamp (selects the pixel at that precice "point").


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...