Hi, I’m wondering if there is any way to smoothly scale a pixel sprite to numbers like 0.75, 1.2, etc and not making it blurry or ‘squashed’.
Heres a picture of scaling a sprite to 0.75 with PointClamp:
Heres a picture of scaling a sprite to 0.75 without PointClamp(Looks better kinda but still blurry):
An example of what I would like to achieve is this which is done in Terraria, a game built in XNA.
sprite without scaling:
sprite with 0.75 scaling:
And heres my draw code:
`` GraphicsDevice.SetRenderTarget(rendertarget);
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, DepthStencilState.None, RasterizerState.CullNone, null, camera.CameraMatrix);
spriteBatch.Draw(PlaceholderTextures[4], new Vector2(-64f, -64f), null, Color.White, 0f, Vector2.Zero, 0.75f, SpriteEffects.None, 0f); //sprite im using to test scaling
for (var i = 0; i < player.Length; i++)
{
player[i].Draw(spriteBatch);
}
for (var i = 0; i < LoadedMesh.Length; i++)
{
LoadedMesh[i].Draw(spriteBatch);
}
spriteBatch.End();
GraphicsDevice.SetRenderTarget(null);
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: Resolution.GetTransformationMatrix());
spriteBatch.Draw(rendertarget, new Vector2(GraphicsDevice.PresentationParameters.BackBufferWidth / 2, GraphicsDevice.PresentationParameters.BackBufferHeight / 2), null, Color.White, 0f, new Vector2(rendertarget.Width / 2, rendertarget.Height / 2), 2f, SpriteEffects.None, 0f);
spriteBatch.End();
ui.drawUI(spriteBatch); //draw ui layer in disregard of transformation matrix
base.Draw(gameTime);
Any help will be greatly appreciated!
EDIT: Solved. By removing the rendertarget thing and instead using Matrix.CreatScale to scale the entire view instead, I managed to fix it. Still using PointClamp.