Author Topic: OpenXCom and hqx scaler  (Read 28289 times)

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
OpenXCom and hqx scaler
« on: November 09, 2010, 01:58:37 pm »
Hi,
this is just an open discussion following on greyhound's blog comment.

Hqx is the only scaler I have experience with, it's fast, opensource and easy to implement (1 single class). (https://en.wikipedia.org/wiki/Hqx)
There is another widely used one called 2xSAI, which seems to do the job very nice as well: https://en.wikipedia.org/wiki/File:2xsai_example.png

In openXcom it can scale raster graphics immediatly after loading them, so there is no scaling going on during the game itself, in contrary to the pixel-stretching it is now doing, which will drastically increase framerate at higher resolutions. Downside is that the scaling is fixed to either 2x 3x or 4x.

But this ofcourse only applies to raster graphics and not to vector graphics like the globe and the user interface elements, which have to be scaled in a mathematical way.

In attachement a preview of what hq3x does in comparison with the standard stretcher set to 960x600.
PS. it's faked, the hq3x is applied after the screenshot, but it's just to get an idea :)
« Last Edit: November 09, 2010, 02:10:01 pm by Daiky »

Offline michal

  • Commander
  • *****
  • Posts: 629
    • View Profile
Re: OpenXCom and hqx scaler
« Reply #1 on: November 09, 2010, 06:08:00 pm »
It doesn't look bad, but i always disabled such scalers (for example in emulators) because i prefered old school pixels ;) With such scalers sometimes image reminds me oil painting :P

Offline bramcor

  • Captain
  • ***
  • Posts: 76
    • View Profile
Re: OpenXCom and hqx scaler
« Reply #2 on: November 09, 2010, 10:30:10 pm »
I would love a more efficient scaler, but like michal I prefer the pixelated look personally.

"Oil painting" is a polite description - in my experience the effect as downright creepy. Maybe not such a bad thing for a game about aliens and UFOs ;)
« Last Edit: November 09, 2010, 10:31:47 pm by bramcor »

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: OpenXCom and hqx scaler
« Reply #3 on: November 09, 2010, 11:51:45 pm »
Yeah, it has some strange effect to it. It does some nice anti-aliasing to diagonal lines and circles.

As for the performance of the current scaler I think that is due to the way it is implemented. In my opinion it should not scale every frame by frame, but just scale the raster graphics at loading time, and then use the pre-scaled graphics for blitting.

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: OpenXCom and hqx scaler
« Reply #4 on: November 10, 2010, 12:51:22 am »
Yeah I don't like the look of those fancy scalers either, but if the algorithms are out there it probably wouldn't be much of an issue to implement them, given everyone else does. :P

I don't think it'd work just by resizing the resources though. You might get a boost from only resizing all the resources at the start but:
- Not all the game's graphics are stored resources, stuff like buttons/windows/etc are drawn on the fly.
- The game would have to account for different screen sizes and redraw everything accordingly. Currently it just renders everything to a fixed 320x200 sizes and only resizes it in the end, which is a lot simpler.
- Scaling algorithms use the nearby pixels to figure out how to "resize" things, so resizing isolated pictures would probably yield worse results than resizing the whole screen image.

Just my two cents. ;)

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: OpenXCom and hqx scaler
« Reply #5 on: November 10, 2010, 04:16:34 pm »
I don't think it'd work just by resizing the resources though. You might get a boost from only resizing all the resources at the start but:
- Not all the game's graphics are stored resources, stuff like buttons/windows/etc are drawn on the fly.
Stuff that is drawn on the fly (=vector graphics) is even easier, you just multiply every coordinate with the scale factor :)
« Last Edit: November 11, 2010, 08:24:12 pm by Daiky »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: OpenXCom and hqx scaler
« Reply #6 on: November 11, 2010, 12:17:46 am »
I don't think it'd work just by resizing the resources though. You might get a boost from only resizing all the resources at the start but:
- Not all the game's graphics are stored resources, stuff like buttons/windows/etc are drawn on the fly.
Stuff that is drawn on the fly (=vector graphics) is even easier, you just multiply every coordinate with the scale factor :)
Easier from a processing point-of-view, harder to go through every single graphic code and add in the multiplication. :P

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: OpenXCom and hqx scaler
« Reply #7 on: November 17, 2010, 01:40:19 pm »
interesting discussion on this topic of scaling/resolutions:
https://forums.tigsource.com/index.php?topic=5185.0

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: OpenXCom and hqx scaler
« Reply #8 on: November 17, 2010, 02:01:21 pm »
it took me 5 minutes to implement vector scaling for the globe :) (I know that is the easiest part)
But it's just to have an idea.
PS. GUI elements are not vector scaled but hq3x scaled (once at startup of the game).

PS2. the framerate on my vector scaled globe is 400, on the tradionally pixel-scaled globe 80.
So it looks better + it's faster. The only disadvantage is that the way the GUI works may need a little rework. (basically all X/Y coordinates through the whole game need to be scaled)
« Last Edit: November 17, 2010, 02:22:23 pm by Daiky »

Offline michal

  • Commander
  • *****
  • Posts: 629
    • View Profile
Re: OpenXCom and hqx scaler
« Reply #9 on: November 17, 2010, 03:11:08 pm »
That looks really nice :D

Offline liamdawe

  • Sergeant
  • **
  • Posts: 27
    • View Profile
Re: OpenXCom and hqx scaler
« Reply #10 on: November 19, 2010, 01:40:46 am »
That actually looks far cleaner :)

Offline sir_nacnud

  • Captain
  • ***
  • Posts: 54
    • View Profile
Re: OpenXCom and hqx scaler
« Reply #11 on: November 19, 2010, 07:09:03 am »
The globe looks really nice, but I don't like how all the text and the rest of the UI is blurry.

Offline luke83

  • Commander
  • *****
  • Posts: 1559
    • View Profile
    • openxcommods
Re: OpenXCom and hqx scaler
« Reply #12 on: January 16, 2012, 01:03:16 pm »
I must of misted this topic way back when ( could of been before i joined) How do these work ? Is there a easy way for me to try this for myself?

Offline Daiky

  • Battlescape Programmer
  • Administrator
  • Commander
  • *****
  • Posts: 904
    • View Profile
Re: OpenXCom and hqx scaler
« Reply #13 on: January 16, 2012, 02:33:17 pm »
The first screenshot was processed with hq3x outside of openxcom. The screenshot of the globe was done with a quick hack in the code. It were just some prototypes, nothing final.

Offline luke83

  • Commander
  • *****
  • Posts: 1559
    • View Profile
    • openxcommods
Re: OpenXCom and hqx scaler
« Reply #14 on: January 16, 2012, 08:53:49 pm »
They look really good, this and Higher Resolutions would be a nice Options to activate on the title screen @ startup. As much as i love the original look i know alof of the young guys i work with wont even give xcom a chance becuase of the pixel look  :( If they could just get past that they would see its the best game ever made :P