This is just a quick follow-up to the dithering post.
Firstly: Yeah, it’s kinda late. Unfortunately, I have been busy with RL and didn’t have much time to work on Gob.
Secondly: Sorry Seldon, but I didn’t get much out of your posts. As far as I understood, it’ll only lead to a lookup that’s far too complex for my needs. The point is a bit moot now anyways, as you can see below. But thanks all the same! 🙂
The actual reason reason for this blog entry is that I did fiddle with the code a bit, though. In some spare minutes, I’ve asked my coworkers/bosses about my problem and they’ve suggested using a more crude approximation of the distance function, namely
ABS(x1 – x2) + ABS(y1 – y2) + ABS(z1 – z2)
This would remove the need for the costly multiplication. Whether it still looks good is a thing to try out. Which I did, and it does.
The bad thing though is that it’s still far too costly to do for every palette entry and every pixel, even when I only look through 15 of them (if I had sorted them in some way, approximating again). After fiddling a bit more, I came to the conclusion that practically everything more complex than a simple array lookup is too costly. Bad. 🙁
That’s why I plan to let gprof look over it, to see where the actual bottleneck might be and how I could change the underlying structure to have it run more optimized. Then I can think about replacing the array lookup. Or I’ll see that I can’t ever think about it. 😉
However, I still wonder how the original did it. Well, it only did static dithering and only over the unscaled video frames (half the x- and y-resolution), but the CPU requirements were far lower too. I could understand it if it build its own palette, but unless I really messed something up in my head, the palette is fixed. The menu, window and text code does use fixed palette entries.
Or maybe I’m just obsessing too much with this rather minor point. It works good enough for now and it might even become obsolete when ScummVM gets real true color support (which might happen during the GSoC this year 🙂 )
Well, that’s it for now, I’ll post the (hopefully soon) next follow-up when I messed about with the profiler.