Page 1 of 2

[Patch] 'Proper' zoom-out

Posted: 13 Dec 2007 21:53
by TheBlasphemer
One of the things that still bother me is how Transport Tycoon zooms out.
Simply discarding 75% of the images really f*** the graphics up.
That's why I set out to create something more pleasant for the eyes :)

The results are quite nice. It's not actually full screen anti-aliased, pulling that off would've required a *lot* more work,
But rather anti-aliased on a per-sprite basis, discarding eventual alpha-channel information.
I tried anti-aliasing the edges too, by taking the average of the transparencies of the pixels, but that resulted in stuff in between tiles not to be re-drawn correctly.
It's all one big hack, but it produces pretty results, so who cares ;)

So, first some screenshots with the new blitter:
aa.2x.png
aa.2x.png (192.17 KiB) Viewed 10541 times
aa.4x.png
aa.4x.png (188.78 KiB) Viewed 10540 times
aa.8x.png
aa.8x.png (104.86 KiB) Viewed 10527 times

Re: [Patch] 'Proper' zoom-out

Posted: 13 Dec 2007 21:54
by TheBlasphemer
Some without

Re: [Patch] 'Proper' zoom-out

Posted: 13 Dec 2007 21:54
by TheBlasphemer
And finally the source

Re: [Patch] 'Proper' zoom-out

Posted: 13 Dec 2007 22:08
by bokkie
TheBlasphemer wrote:One of the things that still bother me is how Transport Tycoon zooms out.
(...)
It's all one big hack, but it produces pretty results, so who cares ;)
Looks great, the 8-bit graphics of TTD an sich don't bother me but zooming out is ugly, so I'd be glad if this gets included into trunk. You say it's 'one big hack' which sounds like the devs won't include it into trunk, is it possible to do it in such a way that it might get into trunk?

Re: [Patch] 'Proper' zoom-out

Posted: 13 Dec 2007 22:18
by Zephyris
You say its "one big hack" but it sounds like a reasonable trade off between true anti-aliasing and speed. A better algorithm for scaling sprites is what is needed, and exactly what you did!

Re: [Patch] 'Proper' zoom-out

Posted: 13 Dec 2007 22:31
by rbenevid
Does the blitter work in 8bpp or is it 32bpp only?

I'm amazed at how good it looks! Great work! Could you post a larger screenshot?

Re: [Patch] 'Proper' zoom-out

Posted: 13 Dec 2007 22:33
by Brainy
I think there's a bug with your blitter. You say that you're discarding a part of the alpha channel. I believe you discarded it all since everything that was supposed to be transparent is now solid black - aircraft shadows, buildings while toggling transparency, etc. Great patch, anyway, I was waiting for something like this for a long time now.

Re: [Patch] 'Proper' zoom-out

Posted: 13 Dec 2007 23:46
by athanasios
I like your patch. Good luck in this little project!

Re: [Patch] 'Proper' zoom-out

Posted: 14 Dec 2007 15:08
by TheBlasphemer
Brainy wrote:I think there's a bug with your blitter. You say that you're discarding a part of the alpha channel. I believe you discarded it all since everything that was supposed to be transparent is now solid black - aircraft shadows, buildings while toggling transparency, etc. Great patch, anyway, I was waiting for something like this for a long time now.
True :)
It discards the alpha-channel entirely, I'll see if I can make a fix that will allow shadows to remain shadows, yet remove the shine-through bug I had earlier...
Thanks for reporting, I hadn't tried shadows while testing ;)
rbenevid wrote:Does the blitter work in 8bpp or is it 32bpp only?
I've only tested on 8bpp, and I'm pretty sure the way I handle alpha-channels currently will mess up most 32bpp graphics ;)

Re: [Patch] 'Proper' zoom-out

Posted: 14 Dec 2007 17:43
by Bilbo
TheBlasphemer wrote: I've only tested on 8bpp, and I'm pretty sure the way I handle alpha-channels currently will mess up most 32bpp graphics ;)
Well, but with full 32bit it should be even easier to downsample the sprite, including correct alpha...

Re: [Patch] 'Proper' zoom-out

Posted: 14 Dec 2007 17:59
by Roujin
Hi there,

your efforts so far look very promising :) I hope you can solve the issues with transparency ;)

What exactly do you mean with
It's all one big hack
?

Are you regarding to coding style and such? It would be a shame if your efforts weren't a candidate for inclusion into trunk because of coding style issues.

Re: [Patch] 'Proper' zoom-out

Posted: 14 Dec 2007 18:09
by belugas
My opinion (not as a dev but as a simple user) is that when zooming out, transparency does not matter anymore. The "higher" you get, the less there is to see.
Zooming out should not be transparency aware. It is not the idea. While zooming, you're looking for a bigger picture, or to admire your network or eventually to try to find ways to connect this or that. So who cares, then if the station is hidden behind a tall office?

Zoom in is a different story, of course. But it's not the subject here.

Re: [Patch] 'Proper' zoom-out

Posted: 14 Dec 2007 18:33
by rbenevid
I agree with Belugas that transparency is not important when zooming out, but making trees invisible is. It's hard
to plan with them hiding the terrain. Even if transparency is turned off when zooming out, invisible trees should continue
to be togglable.

Re: [Patch] 'Proper' zoom-out

Posted: 14 Dec 2007 18:43
by belugas
Well.. invisible trees are not a problem, here. They are invisible because they are not painted, as simply as that.
While the transparency effect is done by using certain properties of the image (don't want to go into details).
So... no problemo :D

Re: [Patch] 'Proper' zoom-out

Posted: 14 Dec 2007 20:03
by TheBlasphemer
I've fixed a few things, including but probably not limited to:
- Made it inherit from 32bpp-optimized blitter
- Made it pass on to 32bpp-optimized if there is no zoom
- Fixed some transparency issues. (e.g. aircraft shadows)

Roujin wrote:Hi there,
What exactly do you mean with
It's all one big hack
?

Are you regarding to coding style and such? It would be a shame if your efforts weren't a candidate for inclusion into trunk because of coding style issues.
Well, I didn't put too much effort into it. I just wrote something that I personally wanted, and didn't really bother with speed, coding style (I just use my own ;)), 32-bit stuff, and all that.
If anyone wants to get this into trunk, feel free to use my source and clean it up, but this current source is just something that I personally use, and is probably not ready for inclusion in a final product ;)

EDIT:
Forgot to mention that I also tried inheriting from 32bpp-anim, to get it to animate at least at no-zoom, but that messed up horribly, and I couldn't really be bothered to find out exactly how to fix that ;)
So no palette animations in this blitter, sorry.

Re: [Patch] 'Proper' zoom-out

Posted: 19 Dec 2007 14:52
by bokkie
Now... how do I use this blitter? I can only compile with BuildOTTD if that's necessary (but I can imagine that that doesn't work), I can't find on the forum or wiki how to use custom blitters.

Re: [Patch] 'Proper' zoom-out

Posted: 19 Dec 2007 17:58
by Brainy
After checking out the source, go to \buildottd\msys\home\ottdsrc\trunk\src\blitter and put the unrar-ed files there. Then modify \buildottd\msys\home\ottdsrc\trunk\source.list (open it with something like notepad) and insert \blitter\32bpp_aa.cpp and \blitter\32bpp_aa.hpp at the end of the #blitter section. Then go to \buildottd\msys and run msys.bat. In the window that opens do a "cd ../ottdsrc/trunk" (case sensitive), after a "./configure" and a "make". You will find the ".exe" in \buildottd\msys\home\ottdsrc\objs\release\openttd.exe. Be sure to copy it and the language files found in \buildottd\msys\home\ottdsrc\objs\lang over to your regular ottd directory. To use the new blitter: openttd -b 32bpp-aa.
Hope I didn't make any mistakes and that it works for you too.

Re: [Patch] 'Proper' zoom-out

Posted: 19 Dec 2007 18:55
by Bilbo
TheBlasphemer wrote:So no palette animations in this blitter, sorry.
Well, these animations greatly increase the time needed to draw things in 32bit display modes (as technically, at every pallette animation tick entire windows has to be read, colors updated and then written back) - and they increase it quite significantly. I am certainly not going to miss them.

Re: [Patch] 'Proper' zoom-out

Posted: 19 Dec 2007 19:16
by bokkie
Brainy wrote:After checking out the source, go to \buildottd\msys\home\ottdsrc\trunk\src\blitter and put the unrar-ed files there. Then modify \buildottd\msys\home\ottdsrc\trunk\source.list (open it with something like notepad) and insert \blitter\32bpp_aa.cpp and \blitter\32bpp_aa.hpp at the end of the #blitter section. Then go to \buildottd\msys and run msys.bat. In the window that opens do a "cd ../ottdsrc/trunk" (case sensitive), after a "./configure" and a "make". You will find the ".exe" in \buildottd\msys\home\ottdsrc\objs\release\openttd.exe. Be sure to copy it and the language files found in \buildottd\msys\home\ottdsrc\objs\lang over to your regular ottd directory. To use the new blitter: openttd -b 32bpp-aa.
Hope I didn't make any mistakes and that it works for you too.
I figured it could be something like that BUT I would never find that out by myself, thanks! Going to try it.

Re: [Patch] 'Proper' zoom-out

Posted: 26 Dec 2007 22:17
by bokkie
It gives an error, these 2 files are missing:

#include "../zoom.hpp"
#include "../gfx.h"

Can't find them in the source downloaded by BuildOTTD itself or by the source I downloaded myself from openttd.org (or my entire pc for that matter ;)). Am I doing something wrong or is there a mistake in the blitter?

EDIT: renaming zoom_func.h to zoom.hpp and gfx_func.h to gfx.h seems to work! Look at me, I'm a hacker! ;)