Double Size Filter Patch

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

Zevensoft
Engineer
Engineer
Posts: 8
Joined: 18 Feb 2006 00:53

Double Size Filter Patch

Post by Zevensoft »

Hello, I have made a patch to enable doublesize (CTRL+D) mode in SDL.
Also I have made some selectable filters to apply to this mode, including:

- None (Default, straight upscale, blocky and fast :) )
- Good (Rounds off text, nice and only slight performance hit)
- High Quality (Attempts to discover vectors within the image and smooth accordingly, very nice image, slow to process)
- TV Filter (Every second line is black, darkens image but might be good on bright high res native LCD displays, fast)

Image

Please try this patch and perhaps give comments :)
Attachments
doublesizefilter.patch
for r7134 (around 0.5 ver I think)
(20.37 KiB) Downloaded 484 times
Quark
Transport Coordinator
Transport Coordinator
Posts: 325
Joined: 20 Sep 2006 11:36
Location: Russia, Moscow

Post by Quark »

hmm, can it work with 32bpp branch?
Last edited by Quark on 14 Nov 2006 03:04, edited 1 time in total.
Image
Zevensoft
Engineer
Engineer
Posts: 8
Joined: 18 Feb 2006 00:53

Post by Zevensoft »

Quark: Not that I know of.

I've edited and redone the patch slightly, also adding a bilinear filter for those who requested it.

edit: changed xfactor and yfactor to vfactor

Also note because of the bilinear filter's preprocess event, it takes a long time to initialize/resize
Attachments
doublesizefilter.patch
Seperated filter code into seperate file
Added bilinear filter
(19.19 KiB) Downloaded 397 times
Zevensoft
Engineer
Engineer
Posts: 8
Joined: 18 Feb 2006 00:53

Post by Zevensoft »

Here is updated version (last ver had really bad initialization code, optimized a bit now)

To enable doublesize mode use CTRL+D (in both win32 and sdl, if problems on keystroke combo make a comment), go to patches menu to change filter.

Sorry these are 8bpp only, I'm looking into 32bpp versions.

filters included:
None (just a blocky doubler)
Diagonal (Seems to work ok on text and newspaper, sharp)
Bilinear (The worlds most common filter)
Vector Smooth (Tries to smooth tracks without wrecking other graphics, may or may not be to your liking)
TV Filter (every other line is black, common filter)
Attachments
doublesizefilter_r7135_v3.patch
for r7135 trunk
(people who dont use doublesize wont feel the init lag for it)
(20.05 KiB) Downloaded 426 times
Quark
Transport Coordinator
Transport Coordinator
Posts: 325
Joined: 20 Sep 2006 11:36
Location: Russia, Moscow

Post by Quark »

awaiting for 32 bpp patch, attaching map fix for it (it is very bad because i was lazy — maybe you rewrite it in the right way)

Code: Select all

--- smallmap_gui.c	Wed Nov 08 15:54:52 2006
+++ smallmap_gui.c	Mon Nov 13 01:55:45 2006
@@ -16,6 +16,7 @@
 #include "tunnel_map.h"
 #include "window.h"
 #include "gfx.h"
+#include "gfx_util.h"
 #include "spritecache.h"
 #include "viewport.h"
 #include "player.h"
@@ -231,8 +232,17 @@
 #	endif
 	}
 #else
-#	define WRITE_PIXELS(dst, val)   *(uint32*)(dst) = (val);
-#	define WRITE_PIXELS_OR(dst,val) *(uint32*)(dst) |= (val);
+//#	define WRITE_PIXELS(dst, val)   *(uint32*)(dst) = (val);
+//#	define WRITE_PIXELS_OR(dst,val) *(uint32*)(dst) |= (val);
+
+static inline void WRITE_PIXELS_OR(Pixel *d, uint32 val)
+{
+	d[0] |= LookupColourInPalette(GB(val,  0, 8));
+	d[1] |= LookupColourInPalette(GB(val,  8, 8));
+	d[2] |= LookupColourInPalette(GB(val, 16, 8));
+	d[3] |= LookupColourInPalette(GB(val, 24, 8));
+}
+
 #endif
 
 #define MKCOLOR(x) TO_LE32X(x)
Grolsch
Transport Coordinator
Transport Coordinator
Posts: 283
Joined: 08 May 2004 07:48
Location: Alkmaar, The Netherlands

Post by Grolsch »

Zevensoft wrote:Here is updated version (last ver had really bad initialization code, optimized a bit now)

To enable doublesize mode use CTRL+D (in both win32 and sdl, if problems on keystroke combo make a comment), go to patches menu to change filter.

Sorry these are 8bpp only, I'm looking into 32bpp versions.

filters included:
None (just a blocky doubler)
Diagonal (Seems to work ok on text and newspaper, sharp)
Bilinear (The worlds most common filter)
Vector Smooth (Tries to smooth tracks without wrecking other graphics, may or may not be to your liking)
TV Filter (every other line is black, common filter)
is it possible to get a preview of every mode in this topic? thanks!
Beer equals power
Zevensoft
Engineer
Engineer
Posts: 8
Joined: 18 Feb 2006 00:53

Post by Zevensoft »

Sure here you go:
Attachments
ottdfilt_bilinear.png
Filter: Bilinear
(177.01 KiB) Downloaded 518 times
ottdfilt_diagonal.png
Filter: Diagonal
(146.42 KiB) Downloaded 475 times
ottdfilt_none.png
Filter: None
(83.1 KiB) Downloaded 527 times
Zevensoft
Engineer
Engineer
Posts: 8
Joined: 18 Feb 2006 00:53

Post by Zevensoft »

- continued -
Attachments
ottdfilt_tv.png
Filter: TV
(83.48 KiB) Downloaded 500 times
ottdfilt_vector.png
Filter: Vector Smooth
(146.85 KiB) Downloaded 641 times
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Post by CobraA1 »

Google 2xsai, that may help.
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
Quark
Transport Coordinator
Transport Coordinator
Posts: 325
Joined: 20 Sep 2006 11:36
Location: Russia, Moscow

Post by Quark »

any news about this patch for 32bpp branch?

there is also good library for scaling screen with Super 2xSaI algorithm and with support for 32bpp
and another (hq2x) algorithm
Image
User avatar
Aegir
Tycoon
Tycoon
Posts: 2884
Joined: 09 Feb 2004 10:02
Contact:

Post by Aegir »

That vector smoothing is mightilly impressive. One question though, could these be implemented as an additional zoom level? as well as the double-size mode?
Currently working under the name 'reldred' on Github, and Discord.
NFO/NML coder, part-time patch writer for JGRPP, and all round belligerent.

14:40 <orudge> I can't say I discriminate against any particular user
14:41 <Aegir> orudge: I can!
Quark
Transport Coordinator
Transport Coordinator
Posts: 325
Joined: 20 Sep 2006 11:36
Location: Russia, Moscow

Post by Quark »

talking about zoom levels, I will glad to see hq2x, hq3x and hq4x zoom :wink:
Image
Grolsch
Transport Coordinator
Transport Coordinator
Posts: 283
Joined: 08 May 2004 07:48
Location: Alkmaar, The Netherlands

Post by Grolsch »

Wow, this vector zoom really looks amazing! Love to see it as an extra zoom-level :)
Beer equals power
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7596
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Post by Born Acorn »

I too would love to see it as an extra Zoom level. Wow the Vector Smoothing looks good.
Image
User avatar
Korenn
Tycoon
Tycoon
Posts: 1735
Joined: 26 Mar 2004 01:27
Location: Netherlands
Contact:

Post by Korenn »

I'm going to jump on the bandwagon:

That vector smooth is awesome. How does it even work?
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Post by athanasios »

As eye candy OK but of what practical value?
Why not lower your resolution instead?
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.
Grolsch
Transport Coordinator
Transport Coordinator
Posts: 283
Joined: 08 May 2004 07:48
Location: Alkmaar, The Netherlands

Post by Grolsch »

athanasios wrote:As eye candy OK but of what practical value?
Why not lower your resolution instead?
:?

Why not buy a bigger screen, why not use a magnifier?

Because it's simpeler to scroll up with your scroll wheel.

Grolsch mumbles something about stupid questions...
Beer equals power
Quark
Transport Coordinator
Transport Coordinator
Posts: 325
Joined: 20 Sep 2006 11:36
Location: Russia, Moscow

Post by Quark »

What about OpenGL-HQ for SDL patch?
  • OpenGL-HQ is a video "driver" for SDL that uses your graphics hardware to scale the output to any size you want. It was originally written for 2D games/emulators like dosbox, scummvm or exult.

    Features    • uses your hardware to get fast scaling
        • scales any 2D SDL program
        • scales with any scaling factor, even fractional ones
        • switches back to the native driver if an app tries to use OpenGL
        • portable
        • configurable like SDL
        • see the screenshots, really

    Requirements    • a Radeon 9600, GeForce 5700 or higher with current driver (OpenGL extension ARB_fragment_program must be supported and hardware-accelerated, EXT_framebuffer_object is also needed)
        • OpenGL-support for your OS in SDL (which means Windows, Linux/X11 or MacOS X)

    How to use
    If you're running on Windows, there is a prebuilt SDL.DLL included in the source archive. Copy it to your application directory, overwriting the old SDL.DLL. Then read the file README contained in the archive to see how to enable it.
Image
iNVERTED
Route Supervisor
Route Supervisor
Posts: 387
Joined: 24 Apr 2005 21:21
Location: Torquay, England
Contact:

Post by iNVERTED »

athanasios wrote:As eye candy OK but of what practical value?
Why not lower your resolution instead?
Because lowering your screen resolution will make TFT screens VERY blurry. Hence why it's better to resize in software.

As for the topic, HQ2X FTW. And I agree that it would be a good idea to implement this as a terrain zoom without changing the size of everything else too.
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Post by athanasios »

iNVERTED wrote:
athanasios wrote:As eye candy OK but of what practical value?
Why not lower your resolution instead?
Because lowering your screen resolution will make TFT screens VERY blurry. Hence why it's better to resize in software.
That's why I don't buy a TFT :wink:
And not the only reason:

1280x1024 :shock: what kinda resolution is this? For dummies? Why don't they make a 1280x1280 also :lol: :lol: :lol: !
Widescreen 1680x1050? :shock: :shock: :shock: I though widescreen is 16:9 aka 1600x900...
WIDE EIZO S2410 1600x1200 for 1600 euros? :oops: EIZO thinks we are fools?
My 200 euro CRT can handle 1600x1200 and many many more custom to play games from any platform, box... Thanks I will not buy.
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.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Ahrefs [Bot] and 14 guests