As you can see from this graphics, no you cannot, I am not allowed to upload. There should be two colours.
basically the two edges of the graphics expand and merge. I want a clean edge
There are 6 graphics here.
The background dark green.
The 4 corners, light green
the four walls all light green.
The background is done first then the graphics of the four corners, Then walls as needing,
This is making a 10x10 corridor.
My question is why do the graphics bleed, blend or what ever it is called instead of being crisp and sharp.
This is my code to start the draw routine.
spriteBatch.Begin( SpriteSortMode.Deferred, BlendState.AlphaBlend );
then my code to draw them out. this all works just do not know why it blends.
spriteBatch.Draw( myWallsTexture, new Vector2( ( float ) ( X * _scale + _Xrow ), ( float ) ( Y * _scale + _Ycol ) ),
new Rectangle( _wall * 10, _modifierWall, 10,
10 ),
Since this is not 100% clear to me…
ehhh… short answer let me copy paste a bit
well if you have some vars for saving your states as class members similarly
public static RasterizerState rasterizerstate;
public static SamplerState samplerstate;
public static BlendState blendstate;
public static GraphicsDeviceManager gdm;
and in the game constructor you hold a reference similar to the below
gdm = new GraphicsDeviceManager(game);
then in initialize
blendstate = new BlendState();
rasterizerstate = new RasterizerState();
samplerstate = new SamplerState();
blendstate = BlendState.NonPremultiplied;
rasterizerstate.MultiSampleAntiAlias = false;
samplerstate = SamplerState.PointClamp;
gdm.PreferMultiSampling = false;
//… maybe fullscreen or what ever else
gdm.ApplyChanges();
then in your draw you pass these to
spritebatch.Begin( SpriteSortMode.Imediate deferred ect… … , … ,… ,…);
pass null for the ones your not setting
that should give you crisp edges in 2d or for 3d polygons
you should note that you need to understand how alpha blending works
and google anti aliasing which is probably what is causing the problem
make sure your images have proper alpha pixels in your paint program of choice along the edges
if you dont want alpha blending at all you should set your blend state to opaque
and should turn off the antialising still
there is one more thing you have to be careful bout.
see here, in this code you are using floats. What happens if you X, Y are not round numbers, for example X = 10.5? SpriteBatch draws that texture and anti-alias kicks in and it changes color of edges.
So you have to snap that texture to device pixels, make sure that X, Y and Size of that texture are rounded to closest “real” pixel, when you draw it. You can start with simple Math.Floor or Round and then read some materials on inet about that issue.