SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 07, 2012 10:46PM
Hello,

I wanted to post about the aspect ratio of SNES9x GX while in 480p mode. Whatever line doubling is done - its slightly off. (I think) I will explain with pictures below.

I have two television setups: 1. a CRT, Sony PVM for low-res games 2. a modern, LED Sony for everything else. I first started using SNES9x GX on my PVM and was really impressed with the 240p output. It is nearly indistinguishable from a real SNES system and Virtual Console titles. I decided to move the Wii to my new HDTV. I noticed that in 480p mode, the resolution was slightly incorrect.

SNES9x GX - 480P - No Filters HDTV


If you look at the yellow blocks you'll see that the two lines within are not the same - one is thicker than the other. This sort of distortion shows prominently if you are playing a horizontal shmup and its almost looks as if the sprites are moving through waves.

SNES9x GX - 480P - No Filters HDTV - Block Detail


I launched the Virtual Console SMW to see if this was an unsolvable issue with the upscaling to 480p. It did not exhibit the distortion at all. Again, this is also 480p mode, same Wii, same TV.

Virtual Console - 480P - No Filters HDTV


Below is a detail of the yellow blocks from the Wii VC edition of SMW.

Virtual Console - 480P - No Filters HDTV - Block Detail


This issue crops up in the Xbox1 port of SNES9x as well. If you set the screen resolution to anything but 512x448 pixels, this distortion will show up. To test in the Wii SNES9x, I reduced the screen's horizontal size to 80%

SNES9x GX - 480P - No Filters HDTV - 80% Width


This looks exactly like the Xbox port's output when set to 512x448. Note that the size of the lines in the yellow block are now the same, but the screen is too skinny.

SNES9x GX - 480P - No Filters HDTV - 80% Width - Block Detail


What is the Virtual Console doing right?! Can this be discerned and the solution applied to SNES9x GX? This is small issue, but I think it would go a long way to improving the fidelity of the emulation.

Any productive comments or ideas are welcome!

Thanks again for a wonderful port!



Edited 1 time(s). Last edit at 01/07/2012 10:53PM by philexile.
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 08, 2012 02:58AM
Virtual Console is simply applying hardware filtering (it's not simple line doubling but more like 256->640 pixels upscaling so you NEED some kind of filter to avoid distorsion).

I am sure that snes9xgx let you enable filtering as well, look into the video settings...
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 08, 2012 03:56AM
Hi, I checked and Virtual Console is not applying any hardware filtering, it is only upscaling correctly. The pixels look the same as in SNES9x sharp and chrisp - aside from the areas of distortion.

Please check out this link which talks about overscan on the NES. While it doesn't discuss the SNES, the concept is the same since they share the same default resolution. See below:

Quote
[u
For emulator developers[/u]

There are two ways to emulate the pixel aspect ratio of the NES: scale before padding and pad before scaling. The NES PPU hardware performs the padding first, adding 24 pixels of border to form a 280x240 pixel picture that can be resized to 320x240, 640x480, or 960x720 square pixels, or to 352x240 or 704x480 if your SDTV output circuit produces non-square pixels at 13.5 MHz. But as a slight optimization, you can scale first (256 * 8/7 = 292) and then pad: stretch the 256x240 pixels to 292x240, 584x480, 876x720, or 1168x960 square pixels or 320x240 or 640x480 non-square pixels. Then you can emulate the overscan by drawing a TV bezel on top of the edges of the emulated picture.]
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 08, 2012 10:43AM
Yes it does. There are different way to upscale horizontally and apply filtering on Wii, some being less visible than heavy bilinear filtering. The thing is, filtering is a necessity when you are upscaling pixels by a non-integer ratio. I think that snes9xgx uses gx bilinear filtering only, which can explain the differences you might see if you use "filtered" mode. Solution is to simply "double" the original width with gx (no filtering needed) then let video hardware do the upscalint+filtering, which is what VC probably does.

Anyway, it is not a problem of wrong aspect ratio or missing border emulation but a common issue with upscaling when trying to output correct aspect ratio. Adding 24 pixels of border then upscaling to 704 would maybe produce a more accurate aspect ratio (though most people probably won't notice it) but scaling artefacts will still exist unless you apply filtering.
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 08, 2012 03:29PM
Quote
ekeeke
Yes it does.

No, it doesn't. If you are so sure that there is filtering present in the Virtual Console edition of SMW - what is it?

Quote
ekeeke
There are different way to upscale horizontally and apply filtering on Wii, some being less visible than heavy bilinear filtering.

What are they and could you post some examples?

Quote
ekeeke
I think that snes9xgx uses gx bilinear filtering only, which can explain the differences you might see if you use "filtered" mode.

It does have a billinear filter and in all the images I posted, it is turned off.

Quote
ekeeke
Solution is to simply "double" the original width with gx (no filtering needed) then let video hardware do the upscalint+filtering,

This is basically what I'm asking for. SNES9x is doing something wrong in 480p. I think that double the resolution (512x448) is actually when SNES9x's screen is set to H=80% and V=100%, as shown in the image below:

SNES9x GX - 480P - No Filters HDTV - 80% Width


SNES9x then takes this screen size and scales it to fit the screen - H=100% and V=100%. 240p mode doesn't have this problem because no scaling is happening. I guess a bad scaling algorithm has been used, which is why its wrong when in 480P mode - but it should be able to be corrected.

Quote
ekeeke
which is what VC probably does.

Correct. VC also scales the image from 512x448 properly. There is not filter applied that I can see - its all sharp pixels. If there is a filter, I'd love to know what it is. We can peak into the SMW wad right?

Quote
ekeeke
Anyway, it is not a problem of wrong aspect ratio . . . .

A very confident statement for someone who hasn't tweaked the code and done any testing. Maybe take a peak at the source if your so inclined. :)



Edited 3 time(s). Last edit at 01/08/2012 04:42PM by philexile.
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 08, 2012 07:09PM
ekeeke is the knowledgeable one in this area. The video code for this emulator is largely influenced by work he's done :)
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 08, 2012 07:33PM
Don't worry, I think I pretty much know what I am talking about and I know snes9xgx video code pretty well, hence why I'm confident of what I am saying ;-)

As I said, filtering is a need when you upscale pixels by a non-integer ratio (which is the case here since 256 "SNES" pixels more or less match 640 "Wii" pixels). If you don't do that, you get scaling artefacts like those wider pixels you are seeing. And yes, it is unavoidable (just think how you could make 2 distinct pixels into 5 without issues), which is why I'm saying that VC does apply filtering.

Also, as I said, there are different ways to upscale the emulator rendered image with Wii hardware:

1) using GX texturing hardware, by specifing a framebuffer width larger than the rendered texture width: this uses bilinear filtering (but can be disabled eventually, that's the "unfiltered" mode)

2) using VI (video hardware), by specifing a video output width larger than framebuffer width: this uses a different filter, less aggressive unless upscale ratio is very large (cannot be disabled).

3) using both, first GX to simply double the width (256->512 for example), which also disable bilinear filtering, then VI for correct aspect ratio (512->640).

In each cases, there is upscaling happening (and yes, even in 240p mode).

Now, Snes9x GX only does 3) in original mode (240p) and does 1) in other modes (480i, 576i, 480p).
In the latter case, you need to pick "filtered" mode to avoid scaling artefacts but also reduces flickering with interlaced modes.

That's why I say it's not a problem of wrong aspect ratio or border or whatever, it's simply a design choice, which prefer to make use bilinear filtering for whatever is not the original non-interlaced video mode (filtered) or let user select a software filter.

Now, I'm not saying this could not be improved: the idea would be to always apply 3) by default unless user wants to enable bilinear filtering, which is pretty much what I am doing in Genesis Plus GX...

In video.cpp/update_video, replace:

		else // unfiltered and filtered mode
		{
			xscale = 320;
			if(vheight == 224 || vheight == 448)
				yscale = 224;
			else
				yscale = 239;
		}


by

		else // unfiltered and filtered mode
		{
			xscale = (GCSettings.render == 2) ? 256 : 320;
			if(vheight == 224 || vheight == 448)
				yscale = 224;
			else
				yscale = 239;
		}



In video.cpp/ResetVideo_Emu, replace:

	else
	{
		rmode = FindVideoMode();
		Settings.SoundInputRate = 31953;
		UpdatePlaybackRate();
	}


by

	else
	{
		rmode = FindVideoMode();
                if (GCSettings.render == 2)
                {
			memcpy(&TV_Custom, rmode, sizeof(TV_Custom));
			rmode = &TV_Custom;
			rmode->fbWidth = 512;
                }
		Settings.SoundInputRate = 31953;
		UpdatePlaybackRate();
	}

and

	GX_SetCopyFilter (rmode->aa, rmode->sample_pattern, (GCSettings.render == 1) ? GX_TRUE : GX_FALSE, rmode->vfilter);	// deflicker ON only for filtered mode

by

GX_SetCopyFilter(rmode->aa, rmode->sample_pattern, (rmode->xfbMode == VI_XFBMODE_SF) ? GX_FALSE : GX_TRUE, rmode->vfilter);



This is untested so I cannot guarantee there is no side-effects, but you got the idea.



Edited 3 time(s). Last edit at 01/08/2012 07:59PM by ekeeke.
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 08, 2012 11:02PM
Quote
ekeeke
Don't worry, I think I pretty much know what I am talking about and I know snes9xgx video code pretty well, hence why I'm confident of what I am saying ;-)

Understood - sorry, I didn't mean that to sound harsh. Thank you for taking the time to explain this to me. See comments below.

Quote
ekeeke
As I said, filtering is a need when you upscale pixels by a non-integer ratio (which is the case here since 256 "SNES" pixels more or less match 640 "Wii" pixels). If you don't do that, you get scaling artefacts like those wider pixels you are seeing. And yes, it is unavoidable (just think how you could make 2 distinct pixels into 5 without issues), which is why I'm saying that VC does apply filtering.

Is there a way to find out exactly what Virtual Console is doing (and copy it)?

Quote
ekeeke
In each cases, there is upscaling happening (and yes, even in 240p mode).

I'm curious, why are there no artifacts in 240p mode then?

Quote
ekeeke
Now, I'm not saying this could not be improved: the idea would be to always apply 3) by default unless user wants to enable bilinear filtering, which is pretty much what I am doing in Genesis Plus GX...

I haven't tried Genesis Plus GX yet. I'll have to give it ago, but I don't think it will have the same issue since its native resolution is 320x240.

Quote
ekeeke
This is untested so I cannot guarantee there is no side-effects, but you got the idea.

I have no idea how to compile. Is there a way to request this change? I'd like to try it out for comparison.

Thanks again!
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 09, 2012 08:44PM
Quote
philexile
Is there a way to find out exactly what Virtual Console is doing (and copy it)?

not trivially, would require to extract the emulator application from channel and disassemble it, without knowing where or what to look for. Anyway, i'm pretty sure it does what I described.


Quote

I'm curious, why are there no artifacts in 240p mode then?

because there IS still filtering... that is what i tried to explain in previous posts.


Quote

I haven't tried Genesis Plus GX yet. I'll have to give it ago, but I don't think it will have the same issue since its native resolution is 320x240.

Well, it still does because some Genesis games use the same resolution as SNES (256x224). Also, there is an option to emulate the horizontal borders as well (28 additional pixels) and, even when 320x224 mode is used, Genesis pixel width is not *exactly* half Wii pixel width so I upscale it a little larger for better accuracy.
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 10, 2012 03:50AM
Give this a try

[www.wiimc.org]
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 10, 2012 07:28PM
Hi Tantric - Thank you! I will load this up tonight!

Quote
Tantric
Give this a try

[www.wiimc.org]
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 11, 2012 03:22PM
Hi Tantric,

I was able to test this out this morning and it seems to be working great - no more distortion! THANK YOU!

How was this accomplished? Could this fix also be applied to FCEUltraGX?

Best Regards



Edited 1 time(s). Last edit at 01/11/2012 05:21PM by philexile.
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 11, 2012 05:23PM
Here I am...
Always following the track of the pixel perfect path!

Dear Tantric, is that possible to apply the same fix to the FCE-Ultra-GX as well?
It would be great if you can compile a new version just like you did with the SNES9x-GX.

Thanks sooo much!
Regards,
Cospefogo.

PS. And thanks Philexile for your efforts on the the subject!
=)
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 14, 2012 11:29AM
Quote

How was this accomplished?

Just like I said..
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
January 14, 2012 03:44PM
Quote
ekeeke

Just like I said..

Brilliant - thank you both! Will this update make its way into the official build?
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
March 05, 2012 06:02AM
Sorry for bump, but a related question: how difficult would it be to implement integer scaling (i.e. raw 2* scale) for 480p mode? I understand that these emus are largely finished, so this isn't so much a feature request as a matter of asking how complicated a source change would be for a lay user. I'm no coder, but if it was a matter of changing a 640 to a 512 and a 480 to a 448 somewhere, then that's probably something I could do.

I know there's already the scaling percentage settings, but since they give only imprecise controls over scaling relative to the default rather than relative to the original image, it doesn't seem like it's possible to get an exact 512*448 display window. The way WiiMednafen handles this is to have a few hardcoded scales (1* raw, 2* raw, full screen) and the ability to set a custom scale--obviously something like this would be a far too complex change (for me, anyway), so I don't mind if any change I was to make cannibalises the full screen mode.

I also understand that this would break the aspect ratio correction done by Snes9x GX, but I don't mind--the ARs aren't outrageously different, to the extent that plenty of games didn't even bother to design around it, e.g. Mega Man X and its oval-shaped wheels, etc.
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
March 05, 2012 07:01PM
This looks exactly like the Xbox port's output when set to 512x448. Note that the size of the lines in the yellow block are now the same, but the screen is too skinny.

Environmental management system



Edited 1 time(s). Last edit at 10/07/2012 07:45PM by hira2.
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
March 06, 2012 11:47PM
Quote
vaguerant
I also understand that this would break the aspect ratio correction done by Snes9x GX, but I don't mind
Well... I hope everybody else does mind about that.

Emulators with wrong aspect ratio are so 90's. =P
Re: SNES9x GX - Aspect Ratio Incorrect (Screen Comparison)
March 07, 2012 07:57AM
Define "wrong". I mean, you obviously mean "[EDIT: in]accurate to the original console", but there's a million cases where that's not going to improve the experience for anyone outside of the nostalgia value.




Is Uniracers/Unirally more of a uniquely insane, stunt-filled racer when the tires are ovals? Is Super Picross a more devilish and rewarding puzzler when you're filling in rectangles instead of squares? Unlikely; these games were clearly designed for square pixels--so why force it when there's no need to? Why should anyone be beholden to the limitations of an old console? Because they got to know those limitations 20 years ago as children? For me, there's plenty of reason to play retro games besides nostalgia, like a lot of them are still excellent games.

Obviously, aspect ratio correction is an important and valuable feature. It should absolutely be included everywhere, and probably even be enabled by default. But should it be the only available option? To me, the absolute original, raw unmodified output is the most important thing to have access to, because it's from there you can do any corrections, scaling, filtering, etc. that you like. That way no matter whether you're seeking accuracy to the design goals of the game's artists, accuracy to the way it looked on TV screens through crazy NTSC filters and such, or just straight-up inaccuracy with those weird edge smoothing filters people like to use for some reason, you can achieve it.



Edited 1 time(s). Last edit at 03/07/2012 08:05AM by vaguerant.
Sorry, only registered users may post in this forum.

Click here to login