2D Sprites hard edges
I've got a few 2D textures which are to be resized, and when they do, they always lose their hard edges - usually, this isn't desireable but for the kind of game I'm making I'd like it if they did, actually. I made sure that if they were made bigger they would retain them by simply resizing the textures in photoshop and retaining the edges there, but now when some of them shrink, the thinner lines disappear.
Does anybody have any ideas of how I can ensure hard edges are retained both for growing and shrinking of textures?
Thanks :)
You could manually generate the mipmaps yourself. Use the .DDS file format to save the textures as that stores all the mipmap levels in it.
You can use the NVIDIA Texture Tools to do that.
You can use the NVIDIA Texture Tools to do that.
You can either enable or disable anti-aliasing when resizing an image to a smaller size. When anti-aliased the outlines will probably be smoothed out. If you keep anti-aliasing disabled you will lose pixels on the outline.
You could restore the outline by creating a drop shadow behind the object. If you then duplicate the shadow a few times it will look less softened.
You could restore the outline by creating a drop shadow behind the object. If you then duplicate the shadow a few times it will look less softened.
If you want a pixelated effect of sprite zoom, like older consoles games you simply set texture filtering to POINT.
If you use pixel shaders you can control texture filtering inside the .fx file like:
If you don't use pixel shaders you can control texture filtering from XNA GraphicsDevice object inside the main Game class:
Note that 0 is the sampler used from SpriteBatch by default.
If you use pixel shaders you can control texture filtering inside the .fx file like:
uniform texture sourceTex;sampler sourceSampler : register(s0) = sampler_state{ Texture = (sourceTex); AddressU = CLAMP; AddressV = CLAMP; AddressW = CLAMP; MIPFILTER = NONE; MINFILTER = POINT; MAGFILTER = POINT;};
If you don't use pixel shaders you can control texture filtering from XNA GraphicsDevice object inside the main Game class:
GraphicsDevice.SamplerStates[0].MagFilter = TextureFilter.Point;GraphicsDevice.SamplerStates[0].MinFilter = TextureFilter.Point;GraphicsDevice.SamplerStates[0].MipFilter = TextureFilter.None;
Note that 0 is the sampler used from SpriteBatch by default.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement