PlainOldPants's Shader Presets

I’m sorry to keep repeatedly bumping this thread today, but I’m just very happy with how this is turning out. This update adds a “Toshiba 1995” preset for the Genesis, NES, and SNES. Just by tweaking the settings of my previous upload, I was able to make the artifacts, noise, and especially this Toshiba TA8867AN NES palette look very convincing to me.

Reminder that all of this is made for 1440p. For bigger displays, I suggest changing the CRT-Advanced mask type from 3 to 1 and increasing the mask size from 1 to 2. As always, for the NES presets, use the Mesen emulator and change your color palette to Raw.

https://www.mediafire.com/file/4r8aw2ggptn6dx1/patchy-userfriendly-fix2-2024-09-25.zip/file

Quick update to decrease saturation to 0.8. I thought I’d sync’d this up already, but apparently I did not. https://www.mediafire.com/file/cmdscvpev3aeyrl/patchy-userfriendly-fix3-2024-09-25.zip/file

There are some rippling artifacts because I had my sharpness set high, at 2.75. Also, I really hate this JPEG compression that keeps ruining my images.

2 Likes

Shader’s looking good!

Maybe this might help.

1 Like

Just fixed a glitch in my noise implementation, and suddenly the noise looks very different from before. I added one more experimental noise setting too.

https://www.mediafire.com/file/5vf6djqhjyb9057/patchy-noisefix-2024-09-27.zip/file

2 Likes

Where do I put the folder in? In Shader_Slang?

I was hoping the file names would help give it away, but just paste all the contents of my shaders_slang folder into your shaders_slang folder. It will overwrite my previous version with the latest version.

This snapshot version here adjusts the Sony color settings a tiny bit and makes a few other tiny fixes. All my changes to this are being very rushed because I have other things going on in my life. If the shader lags really badly for you, switch the connection from RF to Composite; if not, try increasing the RF noise severity and changing the noise random seed.

https://www.mediafire.com/file/zvq68x8ncrkk7re/patchy-snapshot-2024-09-29.zip/file

1 Like

@ynnad4 Please let me know what you think of this new noise behavior. It looks very different now.

Pants, will you do one for the SMS, PSX or N64?

PS1 is probably happening in the future because I own the original hardware with TonyHax to run burned discs, like the 240p suite. SMS is less likely because I don’t own original hardware, though I have heard some late SMS consoles have the early model 1 Genesis’ signal with a slight color modification. If anyone here owns an NTSC SMS, I might upload a couple test patterns on here and have them screenshot their video capture of the pattern. As for N64, there’s a low chance I’ll do it, because I’ve heard that original hardware has changing screen resolutions that current emulators don’t emulate, which would make it difficult to run test patterns.

For now, for PS1 games, I suggest making a copy of the Genesis BlastEm preset and doing these changes:

  • Make a copy of the Genesis BlastEm slangp file in the “ntsc” folder.
  • Look for the line near pass 0 or pass 1 that multiplies the width by “8.000000”, and change that to “4.0”
  • After loading the shader preset in your emulator, change the “Signal Res” setting to 4.
  • Change the “Color Carrier Per-Frame Offset” to 0.5.
  • Under the resolution settings, make sure the thing to detect integer-multiplied horizontal resolutions is enabled
  • EDIT: Turn off the Genesis jailbars, because the PlayStation doesn’t have them. Only early NTSC Genesis/MegaDrives and (I assume) late Master Systems have the Genesis jailbars.
  • At this point please save the preset somewhere in case the next instructions are wrong.
  • To get the CRT effect, use the Append feature to append in this exact order: shaders_slang/ntsc/shaders/patchy-ntsc/afterglow-update0, then shaders_slang/crt/CRT_Sanitized/Thick-Mask-CRT-Advanced.
  • To move the easy settings to the top of the list, use the Prepend feature with ntsc/shaders/patchy-ntsc/allowed-settings/allowed-settings (or whatever it’s called).
  • In CRT-advanced settings, I like to scroll down to the scanline settings and change the setting for something that sounds like “scanline shape bright pixels” from 1.0 to 0.75, which makes the scanlines a little bit harder to see

Just a warning, you absolutely will get crap performance while the in the PS1’s startup sequence, but it’ll become bearable again when the console switches to 240p. As long as it is in 240p and not 480p/480i, you’ll get reasonable performance.

EDIT: Make sure you turn off Genesis jailbars for the PS1 settings.

Hi @PlainOldPants! Firstly, congrats for your achievement with these presets and shaders, It’s a hell of a collection of technical details I don’t understand! :stuck_out_tongue:

Initially I tested the first version and it was very slow on my system, because it was expanding some framebuffers to 8x more or less, so I let it on stand by for a while. Then I tested your last version and you’ve speed things up to a manageable way on my end. So liked it very much.

I intend to use some of it on my presets. I began trying the snes system, which raised this first question: what’s the difference between ntsc/patchy-snes.slangp and Patchy_Presets/SNES-SignalOnly.slangp? (I see they use different number of shaders, but I couldn’t notice any difference visually.)

Second, which one is recommended if I decide to prepend it to some crt preset?

I’ve tested the first with crt-royale-fast and got this:

Compared to standard ntsc I had before:

Is that red push normal or am I doing something wrong?

2 Likes

Thanks. I sure wish it was as accurate as you’re making it sound, but to be honest, I only have so much knowledge. If you read my code, I’m sure you won’t have much of a problem figuring out how I did the effect. The key is to filter the signal both when encoding and when decoding.

Just for now, on Genesis, you might like Guest’s NTSC better. Theirs is set up to artificially retain sharpness and to only add rainbows in places where it looks good. The way I might reach both those same goals in the future without compromising so much on accuracy is with an adaptive comb filter, like the one in shaders_slang/nes_raw_palette/cgwg-famicom-geom.

There are still some performance issues with my implementation:

  • Currently, the shader has terrible performance whenever a game switches to 480i/480p. I’ll have to fix this by adding interlacing support.
  • Appending crt-hyllian after my presets also causes a performance drop. I don’t get this problem with crt-guest-advanced or crt-royale.
  • RF noise is slow because it has to add up about 500 randomly generated sine waves in a for-loop. I did this so that the noise would move across the screen at the correct rates like real hardware. To disable noise, set the cable to 0 (composite).
  • My entire code is just very messy, with some places that can just blatantly be better optimized and cleaned up. It started getting this bad after my fall semester started up.

The difference between the presets in patchy_presets and elsewhere is that the patchy_presets ones add 4 additional passes. At the beginning, there’s a dummy pass added to rearrange the settings and move the commonly used ones to the top of the list. At the end are 3 passes for CRT-guest-advanced afterglow with a fix to make it glow the output of my shaders shader, instead of using OriginalHistory which gets the game’s output directly.

So the main difference is that the SignalOnly presets add afterglow.

I recommend prepending the patchy-snes preset and making your own dummy shader to reorder the settings, but knowing how your shaders are, my default color settings probably aren’t what you want.

The main color settings you’ll want to mess with are:

  • Built-in test patterns (This is actually very useful)
  • R-Y/G-Y/B-Y matrix (0 is the same RGB colors, 1 might not have existed on real CRTs, 2 and 3 are JP, 4 thru 8 are US (7 is the Sony CXA2025AS US, like the NES palette), 9 lets you set the settings yourself)
  • Tint
  • Brightness
  • Color
  • White point
  • Chromatic adaptation
  • Phosphors

You can use Chthon’s program called gamutthingy to add more phosphor gamut LUTs. I’ll soon add a color temperature white point setting, since Grade suggests about 8500K.

I’m not sure about this, but maybe it’s better to keep Terrible Gamut Mode turned off. Just a thought.

And for signal quality, mess with:

  • the various B-Y R-Y filter options (on the leaky integrator, only change the rate)
  • (7) Easy Sharpness (or whatever it’s called)
  • the 2-chip SNES RGB blur amount (I do not own a real SNES, so someone will have to figure out the right blur amount for this)
  • For noise, just change the random seed and the overall severity.

The red push is caused by the “R-Y/G-Y/B-Y formula” setting. You can set it to 0 to turn it off, which will get you closer to the developer’s colors. Apparently, a lot of CRTs in NTSC regions in the 90s were messing with their YIQ matrix to correct from 1953 NTSC color to P22 color, and they had different corrections in Japan than elsewhere. The NES palette called “Sony CXA2025AS US” does exactly this. This happened because of the SMPTE standard still allowing the use of old NTSC hardware, while Japan also had 9300K as its standard reference white. By the 90s, PAL CRTs did not mess with their YUV decoding at all.

To be honest, I haven’t done as much research about these color corrections as I would like yet. My preset settings for the YIQ correction are sourced from just a few random chips’ documentation, but I really need to just sit down and look up a bunch of them. The trick is to search up a bunch of CRTs on Facebook Marketplace and on CRT Database, search for their service manuals online, and if you can find the service manual, search the TV’s jungle chip online and see if you can find its official paper with the R-Y and G-Y settings. It’s a good idea to pay attention to the year that the CRT was made in too. My code converts these settings into a decoding matrix.

4 Likes

Fwiw, the PAL Telefunken I have (from ca. 2000) exhibits a notable difference when displaying NTSC compared to PAL signals, amazingly, this also transfers to RGB 60 Hz signals, which I haven’t observed on the other two TV CRTs I own(ed, one was lost some months ago).

Thank you for the answers.

I’ve put formula to 0 as you recommended and the red push was gone.

There’s a gentle interference in your ntsc version that presents nicely in movement along fringing. I like it.

1 Like

I’ve seen in your Sanitized folder that you chose a very heavy mask to use. Maybe this is the cause of slowness. I tend to use small masks for 1080p displays.

@sonkun’s CRT pictures reminded me that none of my consoles looked like “2-phase” composite on my CRT, so I decided to take some pictures of my own Wii and PS1. I’m glad I did, because this confirms to me that they do have the “2 phase” pattern. I didn’t realize this because my CRT’s comb filter was removing a lot of the 2 phase artifacts.

Here’s a video of how my Wii and PS1 look on my CRT. My HDMI to Composite converter had a similar result on Sonic 1’s waterfall (seriously a cursed image), but it’s not in the video. https://youtube.com/watch?v=LcVa2Lpdpbo

And here are some video captures of my PS1 from my Dazzle DVC100 on OBS, which also has a comb filter. First is the checkerboard, which still has its artifacts. Second is the vertical bars, which get their artifacts comb filtered out better.

In standard NTSC, one line of the video signal is exactly 227.5 color carrier cycles long. That’s what this “2 phase” composite video is. You end up with the color carrier being offset by 180 degrees each line, so it repeats every 2 lines.

The Genesis/MegaDrive has a different pattern in its composite. It leaves the color carrier at the same offset on every line, instead of rotating 180 degrees. I don’t have my Genesis here with me, so here’s how the Genesis looks in my shader with a basic non-adaptive 2-line comb filter. First is the checkerboard, and second is the vertical bars.

So, on the Genesis, we get the opposite effect. The checkerboard pattern is mostly left intact, and the vertical bars get a rainbow pattern.

So: to emulate the Genesis’ composite signal rainbows without ruining checkerboard patterns and other parts of the screen, you have to use an adaptive comb filter.

About “3 phase”, this comes from the NES and SNES. I don’t have a real SNES to confirm this, but on the NES at least, the color carrier is 1.5 pixels wide, and every signal line is 341 pixels. That means there are 227.3333… color carrier cycles per line, resulting in the 3 phase pattern. My current SNES settings have this just ever so slightly off from this, but they’re very close.

4 Likes

Nice. I’m glad my posts inspired this research here. Interesting information you posted.

2 Likes

I just made a small edit to cgwg-famicom-geom to support SNES. The difference is that cgwg-famicom-geom has an adaptive comb filter implementation, while mine is notch filter based.

Edit: Something I didn’t implement on my converted cgwg-famicom-geom is the SNES’s blurry RGB. It should be a tiny bit blurrier horizontally, but you get the point. Everything just became a whole lot sharper.

Edit 2: Download at https://www.mediafire.com/file/mjx94ds59os8xxx/snes-clean.zip/file , based on the names of the folders and files, it should be obvious where to put them.

1 Like

PC-Engine/TurboGrafx-16/Turbo Duo also does 3 phase as well as 2 phase, at least according to NTSC Adaptive and CRT-Guest-Advanced-NTSC shaders.

It utilizes multiple resolutions often, sort of like the PSX.

1 Like

Even some Mega Drive games do 3phase. First example I can think of is Virtua Racing.

1 Like

Please be really careful about this. While I don’t know whether or not the PC-Engine has this same “3 phase” pattern as the NES and SNES (To be honest, I haven’t looked at the PC-Engine’s composite), I seriously don’t believe that any revision of the Model 1 and 2 Genesis/MegaDrives were ever outputting a 3 phase pattern, ever. My Genesis doesn’t even output 2-phase.

I seriously don’t mean any offense to anyone here, but the following line of code is how NTSC-adaptive determines whether to use its 3-phase or 2-phase pattern:

   float phase = (global.ntsc_phase < 1.5) ? ((OriginalSize > 300.0) ? 2.0 : 3.0) : ((global.ntsc_phase > 2.5) ? 3.0 : 2.0);

In other words, it’s only looking at the horizontal resolution of the screen. If it’s 300 pixels or less, it’s 3-phase. If it’s 301 pixels or more, it’s 2-phase. There’s no complicated magic to determine whether the real console would output 3-phase or 2-phase. There’s not even an option for the Genesis/MegaDrive’s signal, which I like to call “1 phase”.

These terms “2 phase” and “3 phase” originate from an older NTSC implementation called Maister NTSC, which used precomputed, hardcoded filters from MATLAB for better performance and clarity. NTSC-Adaptive uses those same filters and phase offsets, but with additional features to improve the overall effect, like the anti-ringing, sharpening, and rainbow banding settings, still with clean, fast code. Doing some archeology, these MATLAB-generated filters are over 10 years old: https://github.com/libretro/common-shaders/commit/02d056220939892a5a4b2fbfd6d83101c318aed7#diff-88b173c57ef901ae0104e2f3533403d5bd10eea1359ff186a689c577bef94b49R6 https://github.com/libretro/common-shaders/commit/c31348649421c085c2c0c6013d3ca57fa9718e0e#diff-0b4d32fb579074853dc6d2d41a2a6b645c40597ee1385eb518ddeebd9adcdd6eR45

This weirdness with the NTSC shaders in shaders_slang, combined with this frustratingly long list of NES palettes, is what ultimately led me to get a real NES and Genesis with EverDrives in the first place. As a 2000s person, I’d only ever played these games through emulation, so I didn’t know what they really looked like when they came out.

2 Likes

Which is why I want to get my hands on original hardware again myself. Seeing Virtua Racing like that indeed throws me off, that pic alone makes me want to see how it outputs on a model 1 Gens with RF output. Composite didn’t exist to me back in the 90’s literally until the 5th generation consoles came on the scene with the composite cable packaged in the box, every system I owned before that all came packaged with the RF cable so that was my experience. I have the main 3 systems of the 5th generation (saturn, ps1 and n64) right now all with their respective original composite cables and a crt to play any one of them for testing purposes, it’s the systems before that generation that I haven’t seen in ages on a crt that I need to see again on real hardware.