Welcome! Log In Create A New Profile

Advanced

Video rendering question for developers of GX emulators

Posted by TheManuel 
Video rendering question for developers of GX emulators
December 04, 2008 06:22PM
I'm just getting started with emulators in the Homebrew Channel and I am facing the same conundrum as with console emulators for the PC in my home arcade machine.

Both the NES and SNES use a video resolution of 256 x 224 (for most games anyway). I run my arcade machine at 640x480 for output to a TV through YPbPr video. Since the Wii outputs at 480p the games in NES and SNES emulators for the Wii I assume are set to a resolution of 720x480.
I understand that since 224 is not a whole-number multiple of 480, you cannot simply double the resolution and call it a day but rather you have to scale the video to fit in the vertical 480 lines the Wii outputs.

The GX emulators offer two alternatives, filtered and unfiltered but both have their problems:
- Unfiltered: the image is scaled by adding odd pixels here and there which keeps the image sharp but really alters the output video. You can see and example of this by loading Super Castlevania IV for the SNES. Look at the life bar, which is two rows of rectangular boxes and you will see some boxes are wider than the others when they're supposed to be of equal size. You can also notice this on in-game text in many games. Look, for instance, at the letter "M" and you'll notice one leg wider than the other.
- Filtered: here everything looks with correct proportions but the image looks blurry. As much as you play with sharpness controls, the blurriness just stares back at you mockingly and you almost have to strain your eyes.

I did notice that when running the games unfiltered but without 16:9 correction, the pixel proportions (as in the Castlevania life bar, for example) do look much better but then the whole image looks stretched since the games are originally 4:3 aspect ratio. I don't know what is at work there but having the image so stretched is not a desirable option anyway (I'll try tonight running the game stretched and then setting the TV to 4:3 and let it do the scaling to see what happens; it did not occur to me last night and that is how I play my 4:3 Virtual Console games).

I'm just wondering if it would be possible to add a third video option that solves the problems above and introduces a new lesser one (in my mind) but at least gives users one more option.
What if you implement a video mode that does not attempt to enforce a 4:3 aspect ratio but rather lets it float? This would be essentially running the video in a 512x448 area inside the whole 720x480 screen. The advantage would be razor sharp graphics since you are scaling the original video signal by a whole number (simply duplicating it) which would eliminate the blur of the filtering and would avoid the need to add odd pixels to correct the aspect ratio. Of course, the disadvantage would be an image with slightly off aspect ratio. It would look at little taller or stretched vertically than the original but not nearly as bad as running the game stretched to the whole 16:9 screen.

Please let me know if this is reasonable or if I'm mistaken somewhere in my view of the situation.
As a caveat, this might all be a moot point if when I play with the emulator tonight I set the image to unfiltered without 16:9 correction and correct the aspect ratio with my TV and all of a sudden realize none of the problems mentioned above are present. Then I'll have to delete my request/post and apologize.

By the way, these emulators are a thing of beauty.
Thank you for sharing your hard work.

Shameless beg:
How about a port of Stella for Atari 2600? I'm that old.

Kind regards.

TheManuel
Re: Video rendering question for developers of GX emulators
December 04, 2008 07:46PM
Original?
Re: Video rendering question for developers of GX emulators
December 04, 2008 07:56PM
Quote
wiiztec
Original?
Huh?
Re: Video rendering question for developers of GX emulators
December 05, 2008 10:24AM
he means "original" mode but this option is probably disabled since you use component cable, right ?
you can still try genesis plus to see this mode in action , basically, this use the exact same video mode (240 non-interlaced lines) as those original consoles and results in sharper image but with only half the Wii vertical resolution...

now, about filtered/unfiltered modes:

they indeed use 480i setting (or 480p if you setup your wii for progressive).

vertically, there is no problem with scaling: the original height is simply doubled and 448 interlaced lines are displayed centered in the 480 lines height video display (your TV does probably not allow you to see more lines btw).
The output in these mode is interlaced video with a real framerate of 30 frames/s when the orginal console is updating graphics at 60 frames/sec, that's why filtering is applied by the hardware to reduce flickering effect, resulting in this blurry output (this probably is less visible when 480p is used or/and filtering option is disabled, but it's still less sharpen that original non-interlaced video mode)

horizontally, this is another kind of problem that you figured yourself: the 256 pixels wide original image need to be stretched to fit the whole TV width, like it was the case with a real SNES (because SNES pixels are not "square", due to the nature of analog video). That in mind, those 256 snes pixels equals approx. 640 Wii pixels (that's probably a little more, I never figured the exact wii dot clock). The problem is that 640 is not divisible by 256, and if you do not use filtering, you could indeed get some distorded/asymetric patterns when the scaling occurs.
But again, filtering (bilinear filtering in the case of Wii hardware) will introduce some blur. The original mode disable hardware bilinear filtering and let the Video Interface do the upscaling itself but I believe this also use some filtering (an horizontal filter is indeed configurable via the VI registers), however it's really unnoticeable and very similar to a real SNES.

As you said, you could simply allow independant scaling (vertical/horizontal) and let the user set the video width to 512 pixels to get an unfiltered and undistorded output but it will be a completely incorrect aspect ratio, not sure if it would be worth to use it just for some more sharpeness
Re: Video rendering question for developers of GX emulators
December 05, 2008 05:23PM
Thanks for the detailed response, ekeeke

Quote
he means "original" mode but this option is probably disabled since you use component cable, right ?
Yes. I output video through component to a progressive scan TV. I'll check genesis plus but the smaller image makes that mode less attractive.

Quote
vertically, there is no problem with scaling: the original height is simply doubled and 448 interlaced lines are displayed centered in the 480 lines height video display (your TV does probably not allow you to see more lines btw).
Ah! I forgot about overscan...

Quote
The output in these mode is interlaced video with a real framerate of 30 frames/s when the orginal console is updating graphics at 60 frames/sec, that's why filtering is applied by the hardware to reduce flickering effect, resulting in this blurry output (this probably is less visible when 480p is used or/and filtering option is disabled, but it's still less sharpen that original non-interlaced video mode)
Well, the output is interlaced video but only if my Wii is set up for 480i, no, or is it forced to interlaced regardless? (I can verify this when I get home)
Also, the original hardware may have generated the video at 60fps progressive but the output would always be down-converted to interlaced before it left the console since nobody had progressive scan TV's in those days so the "original" output as gamers experienced included the flickering as part of the normal state, I suppose.

In general, though, the image is very good.
Last night I stopped using the eulator's 16:9 scaling compensation feature and instead used the TV's aspect ratio adjustment feature to bring the image back to 4:3. As I had noticed before, the asymetry is much less noticeable if at all and the image is not blurry as with bilinear filtering so this is a very nice solution.

I could not quite grasp everything you explained but in the case of no aspect ratio correction and no filtering, is the Wii video hardware allowed to fit the image to the screen and you just feed it a 512x448 output or do you do the scaling in the emulator.
Re: Video rendering question for developers of GX emulators
December 05, 2008 07:47PM
Quote

Yes. I output video through component to a progressive scan TV. I'll check genesis plus but the smaller image makes that mode less attractive.

it does not make the image "smaller", it simply reduces effective vertical resolution to the original ones and will only display even lines, exactly like a real console would do (you got tiny black lines between active ones, like scanline effect on emulators)
this mode looks EXACTLY like original consoles did

Quote

Well, the output is interlaced video but only if my Wii is set up for 480i, no, or is it forced to interlaced regardless? (I can verify this when I get home)
if your wii is setup to 480p then snes9xgx will use 480p for filtered/unfiltered if component cable is detected
as I said, this is still a little blurry (much less than 480i I think) because of the video ouput filters (nothing much we can do I guess)

Quote

Also, the original hardware may have generated the video at 60fps progressive but the output would always be down-converted to interlaced before it left the console since nobody had progressive scan TV's in those days so the "original" output as gamers experienced included the flickering as part of the normal state, I suppose.

not really, this is still compatible interlaced video but lines are displayed at the exact same location on each fields (as opposite with true interlaced display where odd/even lines are alternatively displayed), which result in a non-interlaced display and means that a specific line is exactly refreshed 60 times per second (as opposite to 480i where a specific line is only refreshed 30 times per second)

the result is a non-flickering and visually progressiv image (this mode is actually called 240p) with odd lines of the available 480 TV lines forced to blank (this is what I meant by reduced resolution)



Quote

Last night I stopped using the eulator's 16:9 scaling compensation feature and instead used the TV's aspect ratio adjustment feature to bring the image back to 4:3. As I had noticed before, the asymetry is much less noticeable if at all and the image is not blurry as with bilinear filtering so this is a very nice solution.

that's why I'm not a big fan of this option: TV simply upscale the video signal horizontally (and this again requires filtering) when 16:9 mode is detected and the quality of the scaling varies a lot upon TVs (mine is very bad at that). It's generally better to avoid unnecessary filtering/stretching and keep the TV in 4:3 mode...


Quote

I could not quite grasp everything you explained but in the case of no aspect ratio correction and no filtering, is the Wii video hardware allowed to fit the image to the screen and you just feed it a 512x448 output or do you do the scaling in the emulator.

scaling is done by wii hardware and is entirely configurable
it's just that snes9xgx will always ouput 640x448 (or 640x224 non interlaced in original mode) to respect aspect ratio
the zoom option let you modify the scaling but affect vertical scaling also so this is not a solution
Re: Video rendering question for developers of GX emulators
December 05, 2008 08:25PM
Thanks again.
240p is what I have always wanted to set MAME to output to my TV in my cab but have not yet figured out how to do it (I have to play more with the custom video modes)

Hmm, now you have piqued my interest on that "original" mode.
Why is it not available in SNES9XGX with component cables but avaialable on the Genesis emulator?
However, given that almost all commercial HDTV's are progressive scan only, this option should be fruitless for their owners since the TV's take any interlaced signal fed to them and double-scans it. But for a standard definition TV it should look better or at least "more original".
Re: Video rendering question for developers of GX emulators
December 06, 2008 12:01AM
Original mode does not appear to work on all setups - like mine, for example. I just can't get it to work. My TV just doesn't accept the input. I have component cables and a 720p TV. So I set original mode to be disabled in Snes9x GX if you're using component cables, to prevent anyone from encountering this problem. The menu option is only hidden, that's all.

Who knows, if it was re-enabled maybe it would work for some people with component cables, maybe not. Personally I found unfiltered + component + hdtv to be an excellent combination for a perfect image, so I wasn't concerned with 'original' mode.
Re: Video rendering question for developers of GX emulators
December 06, 2008 12:40AM
I understand.
I will probably try it on my other TV just for kicks but, like you said, unfiltered unadjusted looks probably as good as it will ever look on an HDTV. Low resolution signals in general just don't look to well on HDTV's.
Old games downloaded through Virtual Console don't look any better and I assume they have optimized the output as best as possible.
Re: Video rendering question for developers of GX emulators
December 06, 2008 02:20AM
Quote
ekeeke
and will only display even lines, exactly like a real console would do

Real consoles only displayed even lines?
Didn't they use the sam image for both fields?
Re: Video rendering question for developers of GX emulators
December 06, 2008 12:59PM
Quote

Real consoles only displayed even lines?
Didn't they use the sam image for both fields?

or odd lines, it's not important but lines are always displayed at the exact same location on odd/even fields


this is a trick they used to display a progressiv image at 60hz with a reduced vertical resolution (the internal memory was limited at that time I guess)

it's just a matter of timings: interlaced NTSC ouputs 525 lines per frame (of which, 486 can hold active signal, the rest being for vsync) , which is 262.5 lines per fields . Those lines appears interlaced on TV screen by the fact that one line per field (the last one or the first, depends on the nature of the field) is longer than the others (to make the half of the line),

old consoles simply keep a constant line duration and will constantly output 262 lines, which will always appear at the same location on even and odd fields

that in mind, snes and genesis had interlaced modes too



Edited 2 time(s). Last edit at 12/06/2008 01:35PM by ekeeke.
Re: Video rendering question for developers of GX emulators
December 06, 2008 04:08PM
Quote
ekeeke
it's not important but lines are always displayed at the exact same location on odd/even fields
Do you mean that the scanlines of both fields are congruent (overlap each other)? That's definitely not the case.
Re: Video rendering question for developers of GX emulators
December 06, 2008 05:38PM
Quote
daniel_c_w
Quote
ekeeke
it's not important but lines are always displayed at the exact same location on odd/even fields
Do you mean that the scanlines of both fields are congruent (overlap each other)? That's definitely not the case.

they does not "overlap", maybe I was not very clear: it's just that, a NTSC video signal has approx. 480 visible lines, that you could decomposed in odd and even lines

in interlaced video (480i), odd and even lines are displayed alternatively :

first field (1/60s)
---------------

---------------

----------------


2nd field (1/60s):

+++++++++

+++++++++

+++++++++

result (1/30s)
---------------
+++++++++
---------------
+++++++++
----------------
+++++++++

in that case, a single line is only updated at 1/30s, resulting in 30hz framerate



in non-interlaced video (240p), there is no odd/even field distinction and only odd (or even) lines are displayed ,

first field (1/60s)
---------------

---------------

----------------


2nd field (1/60s):
--------------

--------------

--------------

in that case, a single line is updated at 1/60s, resulting in true 60hz framerate but only half resolution

in progressive video (480p), all lines are displayed on each field

first field (1/60s)
---------------
+++++++++
---------------
+++++++++
----------------
+++++++++

2nd field (1/60s):
---------------
+++++++++
---------------
+++++++++
----------------
+++++++++

in that case, a single line is updated at 1/60s, resulting in true 60hz framerate but this time, at the full vertical resolution
Re: Video rendering question for developers of GX emulators
December 06, 2008 06:09PM
By the way, I tried your original mode in Gen Plus and indeed it is sharper than all the others even in my progressive scan TV.
It would be nice if this option were available on the other emulators even if as part of an "advanced video options" menu, "change only if you know what your are doing".
Although quite frankly, I need to study the image in detail from up close because it's probably not very authentic since the TV is double scanning it to make it 480p which is its native display. I'll have to study the image in detail up close...
Re: Video rendering question for developers of GX emulators
December 07, 2008 03:41AM
Quote
ekeeke
they does not "overlap", maybe I was not very clear: it's just that, a NTSC video signal has approx. 480 visible lines, that you could decomposed in odd and even lines

in interlaced video (480i), odd and even lines are displayed alternatively :
...snip...
in non-interlaced video (240p), there is no odd/even field distinction and only odd (or even) lines are displayed ,
...snip...
in progressive video (480p), all lines are displayed on each field

So we are on the same page.
But no normal TV and none of the old consoles supported 240p, because that would not be NTSC--compatible.
Re: Video rendering question for developers of GX emulators
December 08, 2008 11:03AM
this is not NTSC (or PAL) standard but this still remains compatible and I can guarantee you this worked with all TVs I got so far

it's however true that this is sometime not compatible with some modern LCD or HDTV, hence why nintendo added a "interlaced" mode support in their VC

NES,SNES,TG-16,Genesis,Master System, etc... all that consoles generate a "240p" signal by default, I don't understand what make you so sure they wouldn't ?

please search how analog TV works, I'm a little bored to explain everything all again

EDIT: her's a link that could explain it better than me, obviously, this works for NTSC also

[lipas.uwasa.fi]
Quote

Non-interlaced modes

The official PAL-B/G standard only defines interlaced signals. However, with a small modification to the timings, it is possible to derive a video signal that is very close to standard PAL, but has non-interlaced fields. Even though this kind of non-interlaced mode does not follow the official tv standards to the letter, it can be displayed on a regular tv set.

What does this mean?

In interlaced signal, every second field is drawn at half-a-scanline offset. This creates an illusion of more vertical resolution than there actually is. The adjacent interlaced fields are seen stitched together, as if they formed a full-resolution frame.

In non-interlaced signal, there is no half-line offset. The corresponding scanlines in adjacent fields get drawn in exactly in the same places. Or more pedantically: what were formerly known as "fields" have now become (progressive) frames.

The advantage of a non-interlaced mode is that it is flicker-free. Since all fields (and their scanlines) get drawn on the same location, there is no interlace flicker. The image is very stable and clear.

The disadvantage of a non-interlaced mode is that the perceived vertical resolution is only a half of what it seemed to be in the respective interlaced mode.

Practical uses

Why would anyone want to use a non-interlaced mode on a tv screen if it (seemingly) halves the vertical resolution? Isn't the resolution of a regular tv set bad enough to begin with?

8-bit and 16-bit home computers and video game consoles of the 80's regularly used non-interlaced graphics modes on domestic tv sets. This was in part because they had relatively little graphics memory and a relatively incapable graphics chip generating the signal, but also in big part because (unfiltered) computer graphics flicker like hell on an interlaced display. In order to display a stable-looking (non-flickering) interlaced picture, it needs some heavy low-pass filtering in the vertical direction, and it is impossible to get completely rid of it. In a non-interlaced mode, however, the image is rock-steady and clear, without any filtering or processing.

...



Edited 3 time(s). Last edit at 12/08/2008 11:15AM by ekeeke.
Re: Video rendering question for developers of GX emulators
December 08, 2008 12:41PM
Quote
ekeeke
NES,SNES,TG-16,Genesis,Master System, etc... all that consoles generate a "240p" signal by default, I don't understand what make you so sure they wouldn't ?

please search how analog TV works, I'm a little bored to explain everything all again

EDIT: her's a link that could explain it better than me, obviously, this works for NTSC also

[lipas.uwasa.fi]
Quote

...snip...

I actually did learn about TV signals in University and before that I learned alot about it on my own.
I live to know and understand all that stuff and therefore I am thankfull for the link.

After reading the link I better understand what you wanted to say in one of your older posts.
While I believe that method may work in theory, I have the following problem with it.
I doubt that the signal a TV gets from the antenna or other inputs is able to control the vertical position of the scanlines.

A buddy of mine is a TV technican. I will ask him about it.

I am still 99% sure, that all the old consoles create a normal interleaced signal signal with 480 visible scanlines (for NTSC).
Unfortuantely I have no ways to measure it.
Re: Video rendering question for developers of GX emulators
December 08, 2008 03:21PM
lol, you are a very sceptical one, how many articles on the subject do you need to be convinced ?

Quote

While I believe that method may work in theory, I have the following problem with it.
I doubt that the signal a TV gets from the antenna or other inputs is able to control the vertical position of the scanlines.

huh, it's not theory, it actually how analog TV works and anybody knowing the subject could confirm it to you... you do not really control the vertical position of the scanline, the TV beam simply reacts to some specific level or pulses in the video signal to decide when it should draw the next line and when it should go back to the top-left corner to starts the next field. In the case of non-interlaced output, the video encoder simply controls the signal so that the next field starts exactly at the same point than the previous one (on the contrary, with interlaced signal, the next field starts with one half scanline delta), there is absolutely no magic with this

to simplify, you have to understand that what a TV do is only react to an input signal and this signal (wherever it comes from) controls what you got on TV screen


Quote

I am still 99% sure, that all the old consoles create a normal interleaced signal signal with 480 visible scanlines (for NTSC).

sorry but you are wrong and it's not like it was something that has not been studied already.
the best way to notice is the so-called "scanline" effect... with those old console on a regular TV, you can notice tiny black lines between active display lines, this is part of the signal that remains inactive and blank
sure you got 480 lines on the TV screen because it's NTSC definition, but the video encoder of the consoles only ouputs half of active lines,

depending on TV, this is more or less visible (and there are other kind of NTSC artefacts that could affect the video output) but believe me, I've studied a lot the sega genesis video output before getting an accurate video emulation and i can ensure you that it is exactly how it works ... and console from the same generation did the same

sure, there were "interlaced" modes available for the genesis and super nes but this was not the commonly used video mode as it required more CPU and video memory
Re: Video rendering question for developers of GX emulators
December 09, 2008 05:24AM
Quote
ekeeke
lol, you are a very sceptical one, how many articles on the subject do you need to be convinced ?
I am just trying to understand.
The problem is, the whole idea goes against anything I learned and thought (see, i am using past tense here) I understood about TV signals.
And yes, I am sceptical :D


Quote

link to [www.maxim-ic.com]

...SNIP...

the best way to notice is the so-called "scanline" effect... with those old console on a regular TV, you can notice tiny black lines between active display lines, this is part of the signal that remains inactive and blank

I did not read the article, yet (but I will!)
After quickly looking over it, Figure 2 got me wondering. It definitly describes another scenario than the one I was tought in University.

Nevertheless, you already got me doubting my knowledge.

Unfortunately I have no "old" TV left. All the TVs I could use have some sort of digital mojo.

Can you recommend any SNES game, that shows the "scanline" effect?.
Note: I live in PAL-territories.


Quote

sure you got 480 lines on the TV screen because it's NTSC definition, but the video encoder of the consoles only
ouputs half of active lines,
If I understand you right, wouldn't the active lines be output twice?

Quote

I've studied a lot the sega genesis video output before getting an accurate video emulation
Can you tell me more about that? How did you do it?
Re: Video rendering question for developers of GX emulators
December 09, 2008 06:04AM
Quote
ekeeke
this is not NTSC (or PAL) standard but this still remains compatible and I can guarantee you this worked with all TVs I got so far

it's however true that this is sometime not compatible with some modern LCD or HDTV, hence why nintendo added a "interlaced" mode support in their VC

Just to add to this, the incompatibility I've experience with my HDTV is it outputs all 240p lines without the spacing in between - so it looks "scrunched" in the top half of the screen.
Sorry, only registered users may post in this forum.

Click here to login