getting ill? and working hard …
damn, currently i’m feeling a little bit ill … but i must not get ill now! there’s so much work to do. currently i’m working on the resource management in our game, sounds easy but it’s one of the most challenging things i’ve ever worked on, but let me explain the problem a little bit more detailed.
First something general, how the game architecture is constructed (every point listed is a single thread):
- Rendering
- Network Communication Incoming
- Network Communication Outgoing
- Resource Loading
So far nothing complicated, but now the fun starts:
Further our game consists out of thousands unique textures which are generated just in time as you walk through the world. You now may say that we should pre-render the world and then load the textures from disk, but that’s not that easy … here a realistic example:
- the world is a quad 200 x 200 tiles = 40000 tiles per map
- the half of all tiles are unique which we would have to pre render = 20000 unique tiles
- let’s store them as TGA files because there’s no compression and thus they’re fast to load = 64kb * 20000 tiles = 1250 mb
- wow! 1250 mb of data which needs to be pre - rendered on the client, that’s way too much
Therefore we do this just in time! But that’s not the only problem, the textures are generated in the resource management thread which is running on demand as the render thread requests new textures. so when the resource management thread awakes it pre renders the textures and this can be sometimes a time consuming task, this makes our game stuttering on slow single core computers.
But the problem isn’t that easy to solve due to the nature of java (preemptive multitasking) you can’t assign a thread a specific time which he is allowed to execute a task, so the magic word for today is: CACHING!
there are mutliple ways of caching:
- hit based caching
- time based caching
- cost based caching
- and many more …
after a little bit of brainstorming with some workingmates we decided to combine some of the caching tactics, thus we have now a time & cost based caching which stores unrendered textures asyncronous onto the harddisk according to their costs of how long it took to render them and how long they havn’t been displayed on the screen. and it worked out to be a very nice solution to our problem - we just need to pre render a small amount of textures on the beginning and then we can pre render ahead of time when the player moves through the world.
so that’s enough for now, but there is still much optimizing to do … so let’s hope i’ll not get really ill …