Super blurry textures - XNA

女生的网名这么多〃 提交于 2020-01-23 02:44:38

问题


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&current=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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!