GSoC project: Sprite engine overhaul - Weekly A&O report #6/7

Hi everyone!

Time for some updates. Implementing the actual atlas took quite a little longer than a week, which however, was to be expected. After all it was a rather complex change. During the last two weeks the atlas code has gone through quite some changes. As you may recall in an earlier A&O I described, how I seperated texture internals to sprites and textures.

Atlas after adding 14 sprites

Atlas after adding 7 sprites

The next logical step was to pack several sprites into a shared texture like you can see in the following images:

The whole process works adaptive, meaning one sprite can be added after another. The packer will try to insert the requested sprite as good as it can into the free region(s).

However at some point new sprites wont fit in anymore. As you can see the atlas is already quite full after having added 13 sprites to it.

What happens now is that the packer trys to repack all existing sprites plus the new to be added sprite tighter to the atlas. You can see this process in the following image:

What happens now is that the packer trys to repack all existing sprites plus the new to be added sprite tighter to the atlas. You can see this process in the following image:

From this point on, adding further sprites works adaptivley again.
Eventually no more further sprites can be added to the atlas. Either because the packer cannot find a way to order them good enough. Or simply because it is not possible at all to fit all of the sprites. In this case everything is repacked to a double as large atlas.
In case an atlas reached a maximum size, which depends on the actual hardware, a new atlas will be created.

The following video shows the process during level load time:

For next week lots of clean up needs to be done. Currently the atlas routines run side by side with the old routines. I've as well to fix some minor bugs left and work around some design limited issues as the water rendering.

I think I see 7 sprites on the first illustration, and 14 on the second one

So those sprites being packed together will be shown while the game is loading?

Star and Moon allegedly wrote:

So those sprites being packed together will be shown while the game is loading?

Naw, this is all internal. He's animating it so people can see how his code works.

unC0Rr: yes you are right, just got it off by one as i named the files with 0 indexing.

Star and Moon: as nemo pointed out it's just a visualization of the new internal code. In the old version each sprite was one texture object on the graphics card, while in the new version as much as possible in a shared texture.

You do such a thing because "changing between textures" on the graphic card is a quite costly operation.

Furthermore all draw commands using the same texture could be batched rather than send as many individual draw commands.

I don't get it. Is that code you say? Hiding

User login

Copyright © 2004-2023 Hedgewars Project. All rights reserved. [ contact ]