[Patch] 'Proper' zoom-out

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

TheBlasphemer
Engineer
Engineer
Posts: 7
Joined: 11 Dec 2007 17:39

[Patch] 'Proper' zoom-out

Post 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 10331 times
aa.4x.png
aa.4x.png (188.78 KiB) Viewed 10330 times
aa.8x.png
aa.8x.png (104.86 KiB) Viewed 10317 times
TheBlasphemer
Engineer
Engineer
Posts: 7
Joined: 11 Dec 2007 17:39

Re: [Patch] 'Proper' zoom-out

Post by TheBlasphemer »

Some without
Attachments
2x.noaa.png
2x.noaa.png (105.14 KiB) Viewed 10302 times
4x.noaa.png
4x.noaa.png (102.06 KiB) Viewed 10306 times
8x.noaa.png
8x.noaa.png (89.68 KiB) Viewed 10307 times
TheBlasphemer
Engineer
Engineer
Posts: 7
Joined: 11 Dec 2007 17:39

Re: [Patch] 'Proper' zoom-out

Post by TheBlasphemer »

And finally the source
Attachments
blitter.rar
(1.98 KiB) Downloaded 312 times
bokkie
Transport Coordinator
Transport Coordinator
Posts: 327
Joined: 19 Jan 2007 19:26

Re: [Patch] 'Proper' zoom-out

Post 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?
User avatar
Zephyris
Tycoon
Tycoon
Posts: 2890
Joined: 16 May 2007 16:59

Re: [Patch] 'Proper' zoom-out

Post 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!
User avatar
rbenevid
Traffic Manager
Traffic Manager
Posts: 192
Joined: 14 Oct 2004 20:08
Location: Brazil

Re: [Patch] 'Proper' zoom-out

Post 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?
Brainy
Engineer
Engineer
Posts: 10
Joined: 18 Jul 2003 15:26

Re: [Patch] 'Proper' zoom-out

Post 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.
I am the Superior Intelligence
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Re: [Patch] 'Proper' zoom-out

Post by athanasios »

I like your patch. Good luck in this little project!
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.
TheBlasphemer
Engineer
Engineer
Posts: 7
Joined: 11 Dec 2007 17:39

Re: [Patch] 'Proper' zoom-out

Post 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 ;)
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: [Patch] 'Proper' zoom-out

Post 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...
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: [Patch] 'Proper' zoom-out

Post 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.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Re: [Patch] 'Proper' zoom-out

Post 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.
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
User avatar
rbenevid
Traffic Manager
Traffic Manager
Posts: 192
Joined: 14 Oct 2004 20:08
Location: Brazil

Re: [Patch] 'Proper' zoom-out

Post 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.
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Re: [Patch] 'Proper' zoom-out

Post 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
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
TheBlasphemer
Engineer
Engineer
Posts: 7
Joined: 11 Dec 2007 17:39

Re: [Patch] 'Proper' zoom-out

Post 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.
Attachments
blitter.rar
(1.53 KiB) Downloaded 216 times
bokkie
Transport Coordinator
Transport Coordinator
Posts: 327
Joined: 19 Jan 2007 19:26

Re: [Patch] 'Proper' zoom-out

Post 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.
Brainy
Engineer
Engineer
Posts: 10
Joined: 18 Jul 2003 15:26

Re: [Patch] 'Proper' zoom-out

Post 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.
I am the Superior Intelligence
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: [Patch] 'Proper' zoom-out

Post 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.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
bokkie
Transport Coordinator
Transport Coordinator
Posts: 327
Joined: 19 Jan 2007 19:26

Re: [Patch] 'Proper' zoom-out

Post 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.
bokkie
Transport Coordinator
Transport Coordinator
Posts: 327
Joined: 19 Jan 2007 19:26

Re: [Patch] 'Proper' zoom-out

Post 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! ;)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 24 guests