Castlevania Dungeon Forums

Off Topic => Off Topic => Topic started by: TheouAegis on June 24, 2013, 06:20:16 PM

Title: Pixel-Perfect Up-scaling in Game Maker (sans surfaces)
Post by: TheouAegis on June 24, 2013, 06:20:16 PM
I've been seeing this topic cropping up a bit at GMC. The solution has often been to render the game onto a surface and draw the surface up-scaled or something. This is hardware-dependent -- if your video card doesn't support it, you're screwed. I stumbled upon another feature in GM's video processing that is also hardware dependent, but may work with all video cards. I would appreciate any feedback on this.

First, this is intended for full-screen resolution up-scaling. This does apply to windowed games, however. Still, these days nobody cares about windowed games, especially in low-resolution games. You need to go into the Global Game Settings and enable Full-Screen with Fixed Aspect Ratio. This is important. Also make sure interpolation is disabled while you're there. Now go into every room in your game make sure all view ports are twice the width and height of the view; then reduce the size of the ports by 1 each way. In other words, if you use a view 256 pixels wide and 224 pixels high, the view port should be 511 by 447 (256*2-1 and 224*2-1). Now when the game is run, it should take up the full height (or width if the monitor is portrait-oriented) of the monitor with pixel-perfect scaling, meaning no tearing between tiles and no interpolation.

In windowed mode, there should never be any issue with odd-factored scaling. A 1:1 or 3:1 port-to-view ratio should always yield pixel-perfect scaling. With even-factored scaling, you need to reduce the port by 1 (or increase by 1, but I prefer a smaller port). I don't know why this is; I have my hypothesis, but I'm sure it's way off base. Determining the port size can be handled arithmetically if you choose. The following code would be able to handle it for you:

Code: [Select]
var scale;
//Set scale to the desired factor
view_wport    =    view_wview * 2 - !(scale & 1);
view_hport    =    view_hview * 2 - !(scale & 1);

Once again, feedback would be appreciated. This needs to be tested on more than just my computers to see if it works.

Update: Unless my eyes deceive me, it seems any integral scaling factor should work as long as it is greater than 1. I tried with a 3:1 factor and it seemed to scale pixel-perfect. Thus, it seems 3:1 is the ideal ratio.

Personal Response to Previous Update: Scaling beyond the resolution of the monitor will cause distortion. So while 3:1 could be deemed the ideal ratio (I have always encouraged 3:1 scaling, something I picked up on while viewing screenshots from my alpha engine), it is more likely to overextend the port/window beyond the resolution of the OS if one were to factor in mobile apps. Thus, on a PC 3:1 scaling is the best I think, but for a mobile app the 2:1-=1 scaling is better.
Title: Re: Pixel-Perfect Up-scaling in Game Maker (sans surfaces)
Post by: TheouAegis on June 26, 2013, 05:48:33 PM
Update: I tried changing my monitor's resolution from widescreen to... um... whatever the old resolution was called. Went from 1600x900 native to 800x600. In my case, 3:1 scaling did NOT work. Only 2:1-=1 scaling up-scaled properly in my program. So I'm stick with 2:1-=1 for now.Since I only have two monitors, I can't tell beyond these two.  :-\
Title: Re: Pixel-Perfect Up-scaling in Game Maker (sans surfaces)
Post by: Inccubus on June 27, 2013, 11:34:46 AM
I remember having to deal with this in the passed. But for me this stopped being an issue when I stared designing my projects with 4x size graphics in mind to allow for hi-res graphics sets. When not using hi-res graphics I just make the low-res graphics bigger.