Sign in to follow this  
Endemoniada

Can't win with 2D

Recommended Posts

Hi guys, I just can't seem to win when it comes to making a 2D game. In order for the game to be resolution-independent I'm using textured quads for my sprites and not rendering in screen coordinates. To reduce DrawPrimitive() calls I used one texture like an old-school sprite sheet (usually 8 rows by 8 cols = 64 textures per sheet); but that causes problems with the edges, presumably because of the filtering. To eliminate that I can use single textures but that would require quite a lot of DrawPrimivite() calls as well as sorting. I can also solve the problem by using screen coordinates but that eliminates the resolution-independence which I think I should have. Also, on top of these problems, my textures tend to "shimmer" a little when the quads are moving, most likely because of the floating point coordinates; screen coordinates fixes that but once again I would eliminate resolution-independence. I really don't know what direction to go in.

Share this post


Link to post
Share on other sites
To fix the shimmer, use higher-resolution textures, or project to screen space yourself, and truncate the floating point coordinate.

To fix the edges, use gutters.

Share this post


Link to post
Share on other sites
You can solve the edge-problems by creating a border around each sprite, with the color that it should filter towards. For wrapping tiles, you make the border the same color as the other side of the tile, so that it correctly wraps. For non-wrapping sprites, just make it the same color as the edge, or make it transparent if the edge should be blended to transparency.

I recommend doing everything in screen coordinates however, but drawing them to a separate render-target that you create with a fixed resolution. Then you use that render-target as a texture, and fill the screen with it. That way, all scaling and filtering is done as a last step on a single image, that is your complete frame. This way you should get rid of all scaling issues, with correct display on different resolutions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this