Texture cache / sprite sheet building

Started by
3 comments, last by DrDerekDoctors 18 years, 1 month ago
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?
Advertisement
Lightmap Packing.

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

I use ^that^ for exactly what you are describing. Works great :)
-----------------------------www.devcrunch.com - independant developer forums
Absolutely spot on! Thanks muchly! :)
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.
Ta', I've grabbed it and will give it a look over, although as a C rather than C++ person it'll take a bit longer.

This topic is closed to new replies.

Advertisement