问题
I seem to be getting really blurry textures when I look at my textures up close. I am creating a minecraft-like terrain thing and I would like the textures to be pixelated - like it is made rather than XNA try to smooth it out for me.
Here is how it appears: http://s1100.photobucket.com/albums/g420/darestium/?action=view¤t=bluryminecraftterrain.png
Any suggestions would be much appeciated.
回答1:
It's not related to anti-aliasing... it's related to how the hardware samples the texels in the texture. The default filter in XNA is usually Linear, but to get those "blocky" looking textures you must use Point.
In C# you can set any of your SamplerStates to use PointWrap. This is a combination of point filtering with UV wrapping.
// any state index from 0 to 15, textures usually take 0 first
GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap;
However it must the one assigned to the same register as the SamplerState. eg. register s0 will usually be SamplerStates[0]. Alternatively you can enforce sampler states on the shader, and set your registers there:
sampler2D textureSampler : register(s0) = sampler_state
{
Texture = <Texture>;
MipFilter = Point;
MagFilter = Point;
MinFilter = Point;
AddressU = Wrap;
AddressV = Wrap;
};
You can also force mipmapping off with MipFilter set to None.
来源:https://stackoverflow.com/questions/8338095/super-blurry-textures-xna