How to organize subareas on a bitmap?

Started by
3 comments, last by razorjack 17 years, 6 months ago
Hello, I've got a question of an interesting puzzle problem for lightmap organization. The Problem is that I've different rectangle shaped areas I want to place on textures. New textures should be allocated if there are some rectangles which can't fit anywhere. How to organize this process if you want to have less memory wasting? Of course it would be also important to have a fast algorithm. Best results can be reached by bruteforce, but it becomes unpractical for a high amount of rectangles. Does anybody have an idea? ------ Sorry. My English isn't perfect. I'm from Germany. xD But I'll try my best to answer every question.
My spacesim project blog:http://www.simerge.com/
Advertisement
I'd say, start with the largest patches. When you eventually reach the limit of a texture, start looking for smaller and smaller patches untill you've filled up the texture tightly, preferring patches that exactly match the dimensions of the leftover space.

What we did a while ago was dividing the leftover area into boxes, and trying to fill these as effectively as possible, recursively untill the leftover boxes were simply too small. We used some sort of bruteforcing, in that we tried the whole possibility tree and picked the best solution. The boxes we tried got filled for roughly 95%, quite a decent result methinks. Back then, we couldn't find much on this kind of problem though, this was all we could think up in the few weeks we were given. So perhaps you can think of a way to optimize this method... :)
Create-ivity - a game development blog Mouseover for more information.
Thank you.
I'll try it out.
My spacesim project blog:http://www.simerge.com/
It's actually best to use a tree structure.

Edit: also
These two variant seems to be better.
Thank you both.
My spacesim project blog:http://www.simerge.com/

This topic is closed to new replies.

Advertisement