NTSC shader

I used an encode gamma value of (1.0 / 1.8) and that gave me the same color as double correction (i.e., blargg’s filter + cgwg’s shader default), so single-corrected would probably around 2.0…?[/quote]

I’m sorry to be a stick in the mud, but no amount of fiddling with the gamma made the castle in FFVI shown on my shots up above show up as gray instead of reddish. Something else has to be at work here, unless I’m doing something wrong.

hmm. dunno then.

maister, could that be caused by the conversion to rgb454 (or whatever)?

Yes, it could be. The colored banding in the text box very much looks like it’s caused by having different bit depths in different color channels.

Thank you for the shader Maister, however for some reason the picture comes up a really bright pink/red, i’ve tried to go in and mess around with the YIQ to RGB settings but no luck. If there is a fix for this i’d love to know, otherwise the filter looks great!

You need to build RetroArch from Git. You’re probably not getting the floating point FBOs.

Are you using the 0.9.8.4? You need that version.

http://www.mediafire.com/?ax85bh2r7qx4pyh

Download those. Replace your regular Retroarch exes with it. These are the Win 64 versions.

I’ve ported the NTSC shader to Cg. It’s in common-shaders under NTSC/. PS3 still needs floating point FBOs for this to run correctly though.

I’ve updated the NTSC shader on common-shaders.

  • Change chroma modulation frequency. This greatly helped a particular NES NTSC test.
  • Change to 32-tap decode filter.
  • Change per-frame chroma phases to {0, 180} deg instead of {0, 120}. Excessive fringing is fixed.

Oh man, looks good! It fixes pseudo-hires transparency now:

Oh, that’s nice :smiley: Not sure if it’s really correct though. It scales by 4x horizontally, but for SNES, you’d might want fixed 1024 px output width.

So, I’ve been working on the NTSC shaders lately. There are presets for

  • Gauss scanlines or not (an adapted CRT-geom might be better later)

  • SVideo or not (artifacts/fringing removed, but that’s it)

  • 256px/320px or not.

  • ntsc.cgp and ntsc-svideo.cgp are basically equiv to gauss + 256px, gauss + svideo + 256px respectively.

The 256px/320px stuff requires some explanation. 256px presets force 1st pass to output to 1024px width. This avoids hires material to act differently than regular stuff.

Similarily for 320px. Use it for both 320/640 px width material (N64/PSX). The difference between 256px and 320px is a different chroma carrier wavelength (relative to pixels), and they need different filters, etc. I don’t know of any NTSC filters/shaders intended for N64/PSX, so I cannot compare.

Another difference between 256px and 320px is how burst phases are done. In NES and SNES, it’s 120 degree change per scanline, and offset per frame is 0/120 degrees. For 320px, I’ve used 2 phase with 180 degree offset per frame. Not sure if this is correct.

Some might think this is too blurry. I’m not sure how to filter away the chroma carrier and keep things sharp without looking very ugly. Also, I’m not sure how correct it is for the image to be “sharp” with NTSC, considering the bandwidth is kinda narrow to begin with.

A difference between my approach and Blargg’s is that he samples at a multiple of chroma frequency, while these shaders sample at multiple of luma. That could change some complexity, dunno.

Remember that all screenshots with NTSC will be more artifacty. You need to blend two successive frames to get an impression on how it will look on screen.

The old “diagonal lines” on screen were caused by chroma demodulation. After revising the filters, the stripes are now completely gone.

EDIT: Here’s ntsc-256px.cgp on tvpassfail NTSC test ROM (https://github.com/christopherpow/nes-test-roms/tree/master/tvpassfail). It’s not blended.:

Wow, you’ve done quite a bit, and it all looks really nice. The use of includes is a good idea, keeping all of the shaders short and simple without all of the code dupe.

I’m assuming ntsc-256px-gauss-scanline.cgp needs line 4 to go from this:

shader2 = ntsc-pass3.cg

to this:

shader2 = ntsc-pass3-3phase.cg

My ntsc-256px-gauss-scanline.cgp doesn’t look like that here.

Anyways, updated the decode filters to 64-tap. Should be quite a lot less blurry now at least. Will increase the GPU requirements a bit, but this shader was already quite heavy.

This tweaking never ends … Sigh Figured the result was way too “ringy”, so took a different approach. Cosine rolloff filter is very nice for reducing ringing, at the expense of wider transition band … Changed to a gaussian smear for chroma.

I’ve included the MATLAB files I use to design the filters, so if anyone knows what they’re doing, it’s easy to tinker :stuck_out_tongue:

(For those interested, chroma carrier is Wn = pi / 3 in 3-phase, 4.0 * pi / 15.0 in 2-phase, which explains the cutoffs.)

Oh, dude, I think you really nailed it. The colors look spot-on. Dunno if that’s a result of the chroma smear or what, but it looks great.

Thanks Maister, the shaders rock. I am a bit partial to what I came up with for emulating the look of old televisions but one thing I like about yours is your color correction seems more accurate to what I remember an old NES looking like for instance, is there anyway to get that function in one single .cg shader I could stack onto mine? I’ve already run out of my 8 slots and would have to sacrifice a shader, don’t think I could manage 3-4.!

@solid12345 I don’t think you could ever get it below 3, just by virtue of the way the shader functions. However, if you wanted to incorporate it, you could free up at least one slot by moving the border/background to use the overlay system instead of a shader.

@maister I did some comparisons with blargg’s filter and the differences are very slight at this point. I’m trying to track down someone with an NES flash cart to see how that test ROM looks on actual hardware, since that’s the only example I’ve found where the results are appreciably different. Both versions clearly “pass,” though.

Straight CGPs can have up to 12-13 passes actually. We only expose 8 in RGUI due to GUI clutter. I’ve never tested a CGP with that many passes, so it might not work.

NTSC needs 3 passes to save performance.

Silly me I didn’t know that, I’ll have alot more fun (and headaches) tweaking now!

This shader works great on (s)nes, genesis. How to modify it for PC Engine or Atari 2600/5200/7800? TIA