Jump to content

  • Log In with Google      Sign In   
  • Create Account






Atlasing and More on Composition

Posted by EDI, 29 June 2013 · 335 views

Atlasing and More on Composition 'lo all

Seeing as I've been talking a lot about 2d character composition, I thought I should mention.

If you're writing a 2D game, you should probably be atlasing as it is kind of a no-brainer.

I'll assume some people here don't know what image atlasing is - in a nutshell, the idea is you take all of your 2d source images, and stick them into one large image.

Now in practice this usually ends up being several large images, due to the art asset needs for non-trivial games.

How large should the images be? 2048x2048 is a good number that should cover just about any modern hardware out there.

Why atlas?

There are really no downsides to atlasing beyond the need for a bit of forethought; here are some of the benefits.
  • it reduces the number of times you switch textures in 3D rendering hardware, which is generally expensive.
  • atlasing means storing a lookup rectangle, and if you're going through that trouble already, why not clip all the whitespace from your images.
  • you can design your graphics with ample whitespace for alignment/registration; making your life easier, but knowing it gets clipped for deployment.
  • you deploy fewer files, this means fewer file opens and that can mean faster load times, especially if we're talking thousands of frames.
Atlasing is a job for a computer

If you're going to atlas use an atlasing tool; I can recommend Texture Packer it is a great tool to get you started.

Texture Packer is what we used when we started Revel Immortal, but be aware we outgrew it pretty quick; as of the time of this writing Texture Packer doesn't support a concept of packing into multiple pages (not that we found at least); so if you need multiple atlas pages for your game, it might not be ideal.

After Texture Packer, we moved on to an off-line command-line tool written by the very talented Tom Novelli, who has had a very influential hand in Revel since its HTML5 switch.

Tom saw fit to open source this code, so you can use or re-purpose his powerful atlaser free of charge


After that bit of toil you should end up with nice compact atlases such as this:

Posted Image




Oh right, more on Character Composition...

Per my explanation in a previous post, I decided to make a little visual aid to show how composition works:

Posted Image




Is there a large speed increase due to atlasing?

The short answer to that is yes; having your images in a few large textures, means those textures can remain bound the the appropriate texture stage longer during the construction of the frame.  This allows effective batching.

 

 

I should also add it is just about required for using HTML5, as each induvidual image needed results in an http call, which is comparatively extremely expensive during load time.

Not having tons of graphical experience I will begin trying this out to see if my project benefits from this method. :)

You may want to check and see if your library already does this, some 2D libraries/apis or sprite libraries do, for obvious reasons.

Currently the game I am designing does not have any 2D libs or apis. They are all very small programs wrapped in a single container.

PARTNERS