Sign in to follow this  
DrDerekDoctors

Texture cache / sprite sheet building

Recommended Posts

Hello, I was wondering if anyone had any pointers for writing a program to compile a series of arbitralily sized rectangles into another arbitrarily sized rectangle. I know this isn't really a graphics thing, but I'd imagine that it's mostly used in conjunction with graphics so figured this was the best place to start. Obviously it *can* be done through brute force, but that seems a really wasteful approach. Also I suppose it could be done just by shoving the largest stuff in the top corner first, but again I'm not sure that'd yield the best results. So, anyone have any pointers?

Share this post


Link to post
Share on other sites
Lightmap Packing.

http://www.blackpawn.com/texts/lightmaps/

I use ^that^ for exactly what you are describing. Works great :)

Share this post


Link to post
Share on other sites
I started with the blackpawn code, then needed something better, so I wrote this instead :

Rectangle Packing Code

I use this in Ancient Galaxy at level build time for the lightmap texture packing, and also at runtime at a reduced resolution in order to fit shadow maps into a shadow map atlas.

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