0
\$\begingroup\$

I wrote a Camera class that contains Matrix (for zooming and moving around). When I zoomed it with any zoom scale other than 1, some isometric grids becomes visible on each of my isometric tile.

//Camera.cs
//Producing the matrix from previously set Zoom and Location 
        public static void Update()
        {
            Transform =         Matrix.CreateTranslation(Location.X, Location.Y, 0) *
                                Matrix.CreateScale(Zoom,Zoom,1);
            InverseTransform =  Matrix.Invert(Transform);
        }






//Game.cs
            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, Camera.InverseTransform);

                /* Some Drawing */

            spriteBatch.End();

PS: Actually, I really want these grids to be visible for zoom scale of 1.0f too. Having these grids make my game looks more like a tile-based game.

Before Zoom (Scale = 1.0f): enter image description here

After Zoom (Zooming in): enter image description here

After Zoom (Zooming out): enter image description here

Zooming very close (Grid line appears to be more than one pixels): enter image description here

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Could be aliasing, I mean that at some magnifications the sampling of the grid just happens to skip over the lines you want.

Is it possible to make your grid line thicker than one pixel?

\$\endgroup\$
6
  • \$\begingroup\$ I'll try anti-aliasing and see the result. For grid line thicker than one pixel, I am not sure about that, but it seems to be more than one pixel as I zoom in very close. \$\endgroup\$
    – user1542
    May 13, 2012 at 15:36
  • \$\begingroup\$ I see! The separating line isn't a line you're drawing but the gap between tiles. If you can move your tiles just a wee bit further apart that will do the same thing if my idea is correct, it will give you a wider line so that when rendering it doesn't get skipped. \$\endgroup\$ May 13, 2012 at 15:37
  • \$\begingroup\$ I post a close zoom one, so can you try inspect it and give a comment on it. thanks. \$\endgroup\$
    – user1542
    May 13, 2012 at 15:41
  • \$\begingroup\$ I think I drew it such that there is no gap left over (on normal zooming, ofcourse) but I don't know if the transformation does anything to my setup. \$\endgroup\$
    – user1542
    May 13, 2012 at 15:43
  • 1
    \$\begingroup\$ @user1542, When you start scaling textures up and down, they'll sample the colors around the pixels to know which color to use. This leads to the scaling sampling the transparent pixels you have around the actual tile. You can try and change the sampler to use something like LinearClamp or PointClamp. PointClamp will give you a more pixelized look, but it should take care of the problem. Either that, or you need to draw everything to a rendertarget and then up or down scale that rendertarget, that'll fix the issue as well. \$\endgroup\$
    – William
    May 13, 2012 at 16:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .