Accurately modeling CRT scanline effects?

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
Luke
Posts: 40
Joined: Mon Oct 06, 2008 6:03 pm

Accurately modeling CRT scanline effects?

Post by Luke » Wed Dec 09, 2009 5:31 pm

A lot of emulators (mine included) include a feature to add in "scanline" effects to the NES output when blitting to the display. It seems like the standard approach is to decrease the intensity of alternating scanlines by a constant amount. My question is, is there a more accurate way to simulate this effect? Are all alternating scanlines really less "bright" by a fixed amount? Does the intensity of a single scanline on a CRT remaing constant from the leftmost visible "pixel", to the middle, to the rightmost? Same thing as the display varies from top-most scanline to bottom-most - is there a discernible difference in the intensity?

Hopefully that make sense to some of you, I probably stated this sloppily and the answers are likely over my head. But simulating any possible effects along these lines seem (to me, at least) to be a natural next step for some of the excellent work blarrg has done with his NTSC filter.

User avatar
Dwedit
Posts: 4251
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit » Wed Dec 09, 2009 6:57 pm

'Scanline' effects are just an artificial way to give the picture a texture. More accurately would be to simulate a Shadow Mask pattern or Trinitron-style television. Something like This would be a better approximation of TV texture than just half brightness scanlines.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

LocalH
Posts: 172
Joined: Thu Mar 02, 2006 12:30 pm

Post by LocalH » Wed Dec 09, 2009 10:37 pm

The problem with emulating TV-style scanlines on a progressive display is twofold (here I use the term "scanlines" to properly refer to the actual drawn lines, rather than the blank space inbetween):

1) Scanlines and unused lines are not the same thickness. This makes true scanline emulation at 2x native resolution impossible to do in an accurate form, although it is possible to approximate

2) Scanlines "glow" - this makes a simple 3x or 4x "scanline" implementation inaccurate as well, although once again it's possible to approximate by making one full-intensity line and two lower-intensity lines, and then a blank line

To truly emulate "scanlines" in such a way that it looks like an actual CRT, you'd need a much higher resolution than native, as you'd have to add varying degrees of "faded" lines around the full-intensity line that accurately represents the system's actual contents of that line. I'm thinking that 5x or 7x might visually suffice - one or two full-intensity lines (depending on whether 5x or 7x would work better), two lines of two-thirds intensity, two lines of one-third intensity, and one black line. This still might not be 100% accurate (and 100% accuracy will be practically impossible for the foreseeable future, at least until we get 300dpi displays), but it should look much better than the simple scanline implementations you see nowadays.

Shadow mask/aperture grille emulation is a whole other topic, unrelated to scanlines except insofar as the greater goal of full NTSC CRT emulation is concerned. The Stella "CRT" emulation and NRS/Blargg NTSC emulation have two completely different goals, and it's possible that only part of the Stella solution would be applicable in combination with NRS/Blargg NTSC emulation, as some of the effects that the Stella solution (poorly) tries to mimic are already handled by NTSC emulation.

I am still of the belief that the primary goal for TV emulation has been reached. I don't think emulator authors should really concern themselves with the display artifacts that are a result of the actual electron scanning process - I think they should only worry about recreating the signal as it is output from the system, before display. Basically, if the emulator and a video capture look identical to non-trained eyes, then the emulator has done it's job.

My opinion, etc.

HJRodrigo
Posts: 71
Joined: Tue Sep 15, 2009 5:01 pm

Post by HJRodrigo » Wed Dec 09, 2009 11:22 pm

http://board.byuu.org/viewtopic.php?f=10&t=147

This thread has the best implementation I have ever seen!!!!

User avatar
Dwedit
Posts: 4251
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit » Thu Dec 10, 2009 12:03 am

I wonder if anyone would handle CRT Warping, how when you display very bright screens, the entire screen distorts. Especially noticeable if you are playing Pac-Man on an arcade machine, and beat a level.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

HJRodrigo
Posts: 71
Joined: Tue Sep 15, 2009 5:01 pm

Post by HJRodrigo » Thu Dec 10, 2009 12:53 am

That was actually already done 2. The last page has an example with some warping. Apparently the amount is customizable 2. There are 2 separate filters in that thread, the second one is the filter that even has that as part of its implementation.

LocalH
Posts: 172
Joined: Thu Mar 02, 2006 12:30 pm

Post by LocalH » Thu Dec 10, 2009 11:22 am

HJRodrigo wrote:http://board.byuu.org/viewtopic.php?f=10&t=147

This thread has the best implementation I have ever seen!!!!
Agreed, although it still doesn't look quite right. On a real CRT, there is never any relationship whatsoever between native pixels and phosphors. Thus, where the phosphor3x filter will always create the same effect over a particular 8x8 pixel area, a real CRT may not (and probably will not, given my experience with real TVs and actual hardware).

Perhaps they should use a multiplier that makes some native pixels larger than others - as long as everything is done properly within the algorithm, they shouldn't have to worry about it looking unbalanced.

Post Reply