SNES NTSC Composite Video Filter

Strictly for discussing ZSNES development and for submitting code. You can also join us on IRC at irc.libera.chat in #zsnes.
Please, no requests here.

Moderator: ZSNES Mods

Post Reply
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Re: ZSNESW w/snes-ntsc filter

Post by Nach »

KingHanco wrote:Now you going have to cleanup all the blurry in the window or full screen.
Televisions are blurry.
KingHanco wrote: Another thing is that the screen became a wide screen instead of sqaure screen. :oops:

The tv screen is about 4:3 and this is wrong on the ZSNES.

I'm rolling back to zsnesw-mov for a nice and clear 4:3 sqaure screen.
The only square ratio is 1:1. A square is when a shape has 4 sides, all of them equal in length, and two right angles.
A rectangle is where you have a quadrilateral with two sets of sides with equal length and two right angles.
The day you find a rectange where it's width/height = 4/3 and also happens to magically be a square is the day you need to check yourself into a mental institution.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
DataPath
Lurker
Posts: 128
Joined: Wed Jul 28, 2004 1:35 am
Contact:

Post by DataPath »

The day you find a rectange where it's width/height = 4/3 and also happens to magically be a square is the day you need to check yourself into a mental institution.
Or become a government statistician.
zidanax
Rookie
Posts: 49
Joined: Thu Jul 29, 2004 5:17 am
Location: USA

Post by zidanax »

Hmm, is 640x480 DR supposed to be exactly the same size as 640x480 DS? Both modes are stretched out for me in Pagefault's WIP. In the 2/27 WIP the two modes work as intended.
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

Just for the record - the DKC2 transparency issue persists. (pic)

zidanax:
I think the new code in this build overrides some settings, among them the resolution.
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
pagefault
ZSNES Developer
ZSNES Developer
Posts: 812
Joined: Tue Aug 17, 2004 5:24 am
Location: In your garden

Post by pagefault »

For everyone whining and complaining

This is a TEST. Use it for nothing but testing. No one ever said that this was the way zsnes would be from now on.
SquareHead
Veteran
Posts: 970
Joined: Fri Jan 21, 2005 11:15 am
Location: Montana, United States

Post by SquareHead »

pagefault wrote:For everyone whining and complaining

This is a TEST. Use it for nothing but testing. No one ever said that this was the way zsnes would be from now on.
:lol:

Put in a much better way than I said/could say.

I take it when the time comes, this will be a selectable filter?

I just got the most stupid idea to output this to my tv and see what it looks like.
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

SquareHead wrote:
pagefault wrote:For everyone whining and complaining

This is a TEST. Use it for nothing but testing. No one ever said that this was the way zsnes would be from now on.
:lol:

Put in a much better way than I said/could say.

I take it when the time comes, this will be a selectable filter?

I just got the most stupid idea to output this to my tv and see what it looks like.
Sounds like a disaster waiting to happen. :wink:
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
Sith
Lurker
Posts: 100
Joined: Tue Jul 19, 2005 12:32 pm
Location: Belgium

Post by Sith »

Squarehead wrote:I just got the most stupid idea to output this to my tv and see what it looks like.
:lol:
Last edited by Sith on Wed Mar 01, 2006 10:49 pm, edited 2 times in total.
[url=http://zsnes.ipherswipsite.com/]Zsnes WIP[/url]
[url=http://byuu.cinnamonpirate.com/?page=bsnes]Bsnes[/url] by Byuu
[url=http://www.eidolons-inn.net/tiki-index.php?page=Kega]Kega Fusion[/url] by SteveSnake
[url=http://www.viceteam.org/]Vice[/url] by Viceteam
Reznor007
Lurker
Posts: 118
Joined: Fri Jul 30, 2004 8:11 am
Contact:

Post by Reznor007 »

I think it looks really good(well, as good as composite video can ;) ). The only problem I see is that the bottom line isn't there(should be mostly a green line).
King Of Chaos
Trooper
Posts: 394
Joined: Mon Feb 20, 2006 3:11 am
Location: Space

Post by King Of Chaos »

Hummm, I'm kinda interested to see how this would look outputted to a TV.
Clements
Randomness
Posts: 1172
Joined: Wed Jul 28, 2004 4:01 pm
Location: UK
Contact:

Post by Clements »

As far as I can remember, the filter also looks pretty much like how PAL TVs displayed the image too.
Sith
Lurker
Posts: 100
Joined: Tue Jul 19, 2005 12:32 pm
Location: Belgium

Post by Sith »

Clements wrote:As far as I can remember, the filter also looks pretty much like how PAL TVs displayed the image too.
Nice to know :) , since I'm living in europe. (with PAL all over the place)
[url=http://zsnes.ipherswipsite.com/]Zsnes WIP[/url]
[url=http://byuu.cinnamonpirate.com/?page=bsnes]Bsnes[/url] by Byuu
[url=http://www.eidolons-inn.net/tiki-index.php?page=Kega]Kega Fusion[/url] by SteveSnake
[url=http://www.viceteam.org/]Vice[/url] by Viceteam
blackmyst
Zealot
Posts: 1161
Joined: Sun Sep 26, 2004 8:36 pm
Location: Place.

Post by blackmyst »

Clements wrote:As far as I can remember, the filter also looks pretty much like how PAL TVs displayed the image too.
Actually, I find it to be much more flickery in certain areas, and I know because I've got my SNES right here and still play it from time to time (on several different TV's).

One specific example would be Super Mario World, the edges of bushes in the background of green-ish levels flicker a lot, while on my SNES they're perfectly stable. There also aren't as many light borders around things.

Of course, if it's correct for NTCS displays, and that is its purpose, it's irrelevant how close it looks to PAL (I have no clue, I have never played on an NTSC TV before).

Either way, it still looks fantastic. Awesome how blargg was able to make it look so...analogue. Non-matchematical. Something. Great work.
[size=75][b]Procrastination.[/b]
Hard Work Often Pays Off After Time, but Laziness Always Pays Off Now.[/size]
pagefault
ZSNES Developer
ZSNES Developer
Posts: 812
Joined: Tue Aug 17, 2004 5:24 am
Location: In your garden

Post by pagefault »

The filter works the best at 60 or 120hz for NTSC. There is much less flicker.
blackmyst
Zealot
Posts: 1161
Joined: Sun Sep 26, 2004 8:36 pm
Location: Place.

Post by blackmyst »

Oh, I do use 60hz. I forgot to mention that it's mostly while moving, sorry. When the background scrolls at certain speeds, flicker and/or color anomalies appear, or become more apparent.

It doesn't have much of an impact on the overall look though. Like I said, I don't even know what NTSC really looks like. It's great, and I think I will be using it often.
[size=75][b]Procrastination.[/b]
Hard Work Often Pays Off After Time, but Laziness Always Pays Off Now.[/size]
Sith
Lurker
Posts: 100
Joined: Tue Jul 19, 2005 12:32 pm
Location: Belgium

Post by Sith »

Blackmyst wrote:Like I said, I don't even know what NTSC really looks like.
Me neither, but if Gamecube PAL60 looks anything like NTSC, I could have a pretty good idea...
[url=http://zsnes.ipherswipsite.com/]Zsnes WIP[/url]
[url=http://byuu.cinnamonpirate.com/?page=bsnes]Bsnes[/url] by Byuu
[url=http://www.eidolons-inn.net/tiki-index.php?page=Kega]Kega Fusion[/url] by SteveSnake
[url=http://www.viceteam.org/]Vice[/url] by Viceteam
kieran_
Mugwump
Posts: 824
Joined: Fri Jul 30, 2004 9:05 pm

Post by kieran_ »

pagefault wrote:The filter works the best at 60 or 120hz for NTSC. There is much less flicker.
With VSYNC, right?

The filter looks great, from the screenshots I've seen. I really must try it out.
blargg
Regular
Posts: 327
Joined: Thu Jun 30, 2005 1:54 pm
Location: USA
Contact:

Post by blargg »

When the background scrolls at certain speeds, flicker and/or color anomalies appear, or become more apparent.
This is exactly what happens on NTSC. If you've ever played the NES on an NTSC television, it's much more apparent there. I'll try to explain. Each pixel of some color can appear three different ways, depending on two factors: its horizontal position on screen, and the current colorburst phase for the line. The result is the following combination of different appearances based on location:

Code: Select all

1 0 2 1 0 2 1 0 2 1 0 2 ...
2 1 0 2 1 0 2 1 0 2 1 0 ...
0 2 1 0 2 1 0 2 1 0 2 1 ...
The colorburst phase toggles each frame, so you might get the above pattern on even frames, and the following pattern on odd frames:

Code: Select all

2 1 0 2 1 0 2 1 0 2 1 0 ...
0 2 1 0 2 1 0 2 1 0 2 1 ...
1 0 2 1 0 2 1 0 2 1 0 2 ...
When a bunch of pixels of the same color are together, the phases average out and you see a solid color without any irregularities. A single pixel of a color on black will show the differences much better. Below are some example pixels on the left and what the appear as on the right on even and odd frames (through my NTSC filter). They are expanded 300% to make them more visible.

Image


If the screen isn't scrolling, you can see that each pixel will flicker between two of the three possible appearances (i.e. 0 and 1, 1 and 2, or 2 and 0). If the screen is scrolling at one pixel per frame, pixels will take on phases 2, 2, 1, 1, 0, 0, 2, 2, 1, 1, 0, 0, etc. This will be clearly visible as a shimmer. Some games scroll a fractional number of pixels per frame, which results in a more complex pattern. For example, 1.5 pixels per frame works out to actual movements in the 1, 2, 1, 2, 1, 2 pattern (averaging 1.5 pixels), and pixels at this scroll rate could appear in an alternating pattern or stay the same phase all the time; if they stay the same phase, you'll see the color artifacts much more clearly, as when you stop the emulator.

This also helps explain why it's important for the monitor's refresh and emulator's frame rate to be the same. Once a GUI is added to adjust the NTSC filter paramters, you'll be able to turn on field merging, which is like mixing the two phase arrangement diagrams above together, eliminating most of this flickering (but also eliminating the shimmer effect when you scroll, making it less-authentic). The result is that pixels appear every frame as a mix of the two possible phases for that position:

Code: Select all

1+2 0+1 2+0 1+2 0+1 2+0 1+2 0+1 2+0 ...
2+0 1+2 0+1 2+0 1+2 0+1 2+0 1+2 0+1  ...
0+1 2+0 1+2 0+1 2+0 1+2 0+1 2+0 1+2  ...
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

I read somewhere about that (in one of the forums you're posting in, I think) ... some sort of NTSC signal / frequency / interference is moving over the screen with a certain speed; on non-moving pictures it stays hidden, but when stuff moves at the same speed over the screen and your eyes follow it, you can see it.
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
OptiRoc
Rookie
Posts: 18
Joined: Mon Jan 10, 2005 12:31 am

Post by OptiRoc »

This is just flippin' awesome!
SteveSnake
Rookie
Posts: 11
Joined: Thu Mar 02, 2006 8:41 pm

Post by SteveSnake »

Another thing is that the screen became a wide screen instead of sqaure screen.

The tv screen is about 4:3 and this is wrong on the ZSNES.
Heh, I get this type of thing all the time. People really do need to go look at a *real console*. There's no convincing them that this is actually correct. Ah well ;)
blargg wrote:The colorburst phase toggles each frame, so you might get the above pattern on even frames, and the following pattern on odd frames:
Ok, this might not be accurate, due to something that you probably don't realise (not many people seem to.)

Most consoles (NES and SNES included) never output odd and even frames (unless, of course, they have a setting for interlaced mode). Every single frame output is in fact an even frame. This is why you get the 'scanlines' effect.

In other words, it is not the TV that decides if this frame is odd or even, but the input signal. So it's perfectly possible (and desirable for low res consoles) to always output even frames at a full 60hz.

So you probably don't want to be toggling the colorburst phase each frame. Which will only make it look better, so it's all good ;)

Nice work, by the way.
KingHanco
Hazed
Posts: 79
Joined: Sun Feb 26, 2006 8:08 am

Ok.

Post by KingHanco »

Guys I know now that this is for the PAL or regular tv only.

I have 2 tv's.

Small one almost a square screen tv.

But my big one is a rectangle size tv.

I can tell now that there no sharp areas on the both screen. Both have alittle blurr on both screen.

My big one sure does look like it have some very light scanlines on the screen. I can very see it on the screen. :)

Btw: I sorry about those post by the way.

Keep up the good work.
blargg
Regular
Posts: 327
Joined: Thu Jun 30, 2005 1:54 pm
Location: USA
Contact:

Post by blargg »

Ok, this might not be accurate, due to something that you probably don't realise (not many people seem to.) Most consoles (NES and SNES included) never output odd and even frames (unless, of course, they have a setting for interlaced mode). Every single frame output is in fact an even frame. This is why you get the 'scanlines' effect. [...] So you probably don't want to be toggling the colorburst phase each frame.
The effect you get with the NES and SNES is more subtle, something different than you describe. I should have used a different term than field, since it's not related to NTSC fields. Like you say, these consoles always output an even field, resulting in the TV giving you a nice 60 frames per second progressive display, albeit at half the vertical resolution as an interlaced NTSC signal would give you, and with black space between scanlines.

A proper NTSC signal's colorburst changes phase by 180 degrees each scanline, resulting in only two possible colorburst phases and every other scanline having the same phase. The same scanline in different fields should also have the phase reversed, so that the phases visually cancel in both the time and spatial domain. This allows a TV without a comb filter to look decent. In simplified terms, it's like a checkerboard that's constantly inverting every field, resulting in a gray appearance. Modern LCDs even do something similar, but for an entirely different purpose (the liquid crystal elements require an alternating current; DC destroys them).

Anyway, the NES and SNES colorburst only shifts by 120 degrees each scanline, so it takes three phase shifts before it returns to the original phase (120 * 3 = 360). This results in three different colorburst phases. Between frames, the colorburst at first scanline (normally) shifts by 120 degrees on even frames, and -120 degrees on odd frames (the PPU waits an extra pixel clock every other frame). This results in a static image displayed (title screen, etc.) actually outputting two distinct alternating composite video frames. It is these that I confusingly referred to as even and odd fields.
Which will only make it look better, so it's all good.
It actually makes it look worse, since the color artifacts don't get blended away as much. Putting aside my explanation of why, empirical data prove that the initial colorburst phase does toggle between frames, and the visual result matches what you see on a TV.

Just to reiterate, it's not like this on the Sega Genesis and many other older consoles; on these, the colorburst is the same phase every scanline. I'm making steady progress and would like to help make a version for the Sega Genesis, if you're interested. What I really want to do is document my algorithm so people can understand how it works (it's interesting) and perhaps write their own implementation.
King Of Chaos
Trooper
Posts: 394
Joined: Mon Feb 20, 2006 3:11 am
Location: Space

Post by King Of Chaos »

blargg wrote:Just to reiterate, it's not like this on the Sega Genesis and many other older consoles; on these, the colorburst is the same phase every scanline. I'm making steady progress and would like to help make a version for the Sega Genesis, if you're interested. What I really want to do is document my algorithm so people can understand how it works (it's interesting) and perhaps write their own implementation.
That's good news. I'd like to see this in Kega someday. There is allready interest for this in Kega. :D
Sith
Lurker
Posts: 100
Joined: Tue Jul 19, 2005 12:32 pm
Location: Belgium

Post by Sith »

Yup, ppl at the Sega emulation board are excited too since they know abt it.
What you just stated, to help out on a Genesis version is very welcome, Blargg. :)
[url=http://zsnes.ipherswipsite.com/]Zsnes WIP[/url]
[url=http://byuu.cinnamonpirate.com/?page=bsnes]Bsnes[/url] by Byuu
[url=http://www.eidolons-inn.net/tiki-index.php?page=Kega]Kega Fusion[/url] by SteveSnake
[url=http://www.viceteam.org/]Vice[/url] by Viceteam
Post Reply