Showing posts with label glsl. Show all posts
Showing posts with label glsl. Show all posts

Thursday, June 1, 2017

New NTSC Shaders

NTSC simulation/emulation is a tough nut to crack. There's a lot of math involved, and the results are very dependent on games/content having the correct resolution or else the effect falls apart. Themaister's NTSC shader does a fantastic job with both 256- and 320-pixel-wide content, which covers most modern-ish retro consoles, including S/NES, Genesis, PS1 and N64, and it handles content of arbitrary resolutions pretty well. Nevertheless, it's always good to have variety, so I was excited to find some other shaders that included different takes on the NTSC signal problem.

Artifact Colors

This shader is based on Flyguy's awesome "Apple II-Like Artifact Colors" shadertoy and is the most impressive/magical of the shaders I'm going to cover here. Where this shader excels is in reproducing the NTSC "artifact colors" that certain old computers depended on before full-color interfaces were a thing. You can find some great explanations of the phenomenon at the 8088 mph demo writeup and this post at nerdlypleasures.

This splitscreen image demonstrates just how mind-boggling this effect can be, taking a 1-bit black and white image and ending up with bright colors:
RGB output on the left, composite artifact output on the right. Those colors are all generated by the signal modulation :O
And here's an animated gif that cycles between the typical limited-palette RGB output and the full-color artifact-color version (half RGB and half composite artifact back and forth):
Notice how the magenta and black stripes turn to a rich brown
In porting this shader, I tried to make runtime parameters out of as many variables as possible because it's such a cool thing to see how they affect the emergent colors in real-time. One such parameter is the F_COL variable, which can be used to basically have another color palette that you can switch to.

I also made a preset that pairs it with T. Lottes' CRT shader, which is perfectly suited to CGA content:
I called this one c64-monitor in the 'presets' subdirectory of the shader repos
I made the presets force a 640-pixel width, since that seems to be the sweet spot for this shader, which isn't surprising seeing as many of the games that relied on artifact coloring used a 640x200 mode. I'm not very familiar with any of the classic computer cores that could take advantage of this shader, but I'd love to hear comments from anyone who gives them a shot.

This preset also looks pretty darn good for general use, though it does a strange green/magenta strobe thing on Sonic's waterfalls and probably other pseudo-transparency:

CRTSim

This one from J. Kyle Pittman / PirateHearts is similar to the CRT effect in You Have To Win the Game:
It doesn't try to be accurate, it just looks nice and runs fast. While it does the whole bevy of old TV effects, including a really nice per-channel color persistence that can be used to reproduce the characteristic red smear of a failing CRT, my favorite part of it is the LUT-based NTSC effect. It uses a simple texture of diagonal colored lines:
This looks gray, but it's actually red, green and blue diagonal lines
and mixes it in with the main image based on differences in brightness between each pixel and its neighbors. For such a simple concept, the result is very convincing, and it even does a reasonable job of "passing" the NTSC crosstalk test-ROM (with certain settings):
Also of interest with this shader is the choice of permissive public domain licensing, so people can integrate it into their games and other programs without fear of licensing conflicts.

Both of these shaders are available in RetroArch's regular GLSL and slang/Vulkan formats. Artifact Colors is also available in RetroArch's Cg format and for ReShade, courtesy of user Matsilagi, who has also ported a number of other RetroArch shaders to ReShade. On-topic but not pictured are two NTSC shaders derived from MAME's NTSC shader implementation, one multipass and one single-pass. I haven't gotten them to work properly in GLSL format, only slang, and all of my Vulkan screenshots have their red and blue channels swapped for some reason right now, so I couldn't share any shots of them. You can get a taste from their shadertoy implementation, though.

Thursday, April 25, 2013

Multipass Shaders - NTSC, Motion Blur and More

It's been a while since I've done one of these posts and, in that time, RetroArch's multipass shader implementation has matured quite a bit, paving the way for a lot of really cool effects that simply can't be done in a single pass. At the time of this writing, higan's multipass shader implementation hasn't been released yet, but many of these shaders should be portable to it (with some substantial effort, at least) when it arrives.

As always, images were captured at 4x scale. Click the thumbnails to embiggen.

First up:
Themaister's NTSC Shader
Themaister wrote a sweet new real-time NTSC Composite shader that mimics a lot of the noise, fringing and crosstalk present in the NTSC composite signal:
This shader is a big deal because blargg's CPU-based NTSC filter was previously the only way to get this effect, which was important in some older games' art design. However, the filter had to be hardcoded to the individual consoles' specific resolution, which made it a headache to maintain in a multi-console setting. This shader should work on all of RetroArch's cores, and it is available in GLSL and Cg/cgp flavors.

I mixed it with cgwg's CRT shader and ended up with this (ntsc2-crt.shader):
You can compare that with an earlier version I cobbled together from the old NTSC shader--which tended to be finicky and not everyone liked anyway--and cgwg's CRT (crt-geom-interlaced-flat-ntsc.shader):
Digging through an old thread on byuu's forum, I also found where cgwg had written a similar shader that combined NTSC with CRT in 6 passes with barrel distortion (6-pass-ntsc+crt2.shader):
In the same thread, cgwg had posted this shader, called 'beam-dynamic,' that is essentially the same result as the beam4 shader mentioned in one of my other posts:
Out of all of these variations, I think my favorite is Themaister's NTSC with the addition of scanlines that have been softened with gaussian blur (ntsc2-maister-scanlines.shader):

Harlequin's Gameboy Shader
This shader does for Gameboy emulators what cgwg's CRT does for regular consoles, i.e., recreates the look of the original display with startling verisimilitude:
I'm not going to spend a lot of time talking about this shader here, even though it's completely badassed, since it's covered at length in a previous post. It's available in Cg/cgp format only, though you can use Themaister's handy cg-to-glsl python script to convert it to GLSL if necessary.

Harlequin's LCD Shader
Using some of the same concepts from the Gameboy shader, Harlequin is also working on a more generalized shader that mimics the low-resolution, slow-refreshing color LCD displays from a number of handheld consoles, such as Sega's Game Gear and Nintendo's Gameboy Advance:

Similarly, cgwg posted an LCD shader he's been working on that produces a regular, square pixel grid pattern, paired with some simple motion blur (lcd-cgwg.shader):


Motion Blur
Speaking of motion blur, I wrote a multipass version of this shader a while back and cgwg revised it down to a single pass (refers to previous frames, so still incompatible with higan v092 and earlier). This effect can be good for mimicking the slow response time of crummy LCDs (motion blur.shader):
I also made a version that only adds the blur during rewind, along with a little sepia-tone effect, kinda like the rewind effect in Braid (braid rewind.shader):
This shader can be added before pretty much any other shader (either manually by pasting in the code or by using the new, built-in RGUI shader stacking function and/or glslp shader configuration files) at a scale of 1.0 and the effect will only kick in when the game is rewinding :D

GTU
This shader from aliaspider is an interesting take on the CRT paradigm insofar as he didn't want to focus on phosphor emulation or heavy-handed scanlines or any of that other jazz. He was more interested in the blurring/blending effect of CRTs that enabled tricks like pseudo-hires transparency and color dithering. Later revisions include some sweet gamma correction and the ability to create mild scanlines (if you choose; GTUv031-multipass.shader):
I think this is one of the best ways to get pseudo-hires transparency working properly, and the transparency it creates is smooth and absolutely beautiful:
Aliaspider made a single-pass version of the shader that should work in higan v092 and earlier, along with the multipass version linked above for RetroArch, and a multipass version for higan v093's upcoming shader implementation.

My 4k Phosphor Shader
This is another one that I won't spend much time on, since I cover it at length in another post:
This shader currently doesn't look so hot as it's designed to work at around 10x scale (i.e., on a 4k resolution television or other high-DPI display; it gets wrecked by subpixel behavior at current normal scales [read: 1080p]). However, it brings some nice things to the table, such as easily-edited LUTs that can be created/modified in Photoshop/GIMP rather than a text editor and scale-ability to freaky-huge resolutions. I'll attempt to convert this to byuu's higan v093 format at some point, though it may take some time.

Thursday, March 3, 2011

Themaister's Waterpaint and Scanline Pixel Shaders for SNES

Themaister, author of the excellent libsnes interface SSNES, has been working on some really fantastic GLSL pixel shaders for use with compatible emulators, such as bsnes and SNES9x.

First, we'll take a look at the waterpaint shader, which has an effect similar to smoothing filters, such as SuperSaI, but with a little extra fattening that gives it the appearance of a watercolor painting:
This looks great already, but text can sometimes get a bit hard to read and some details get flattened out, so he also made a version that includes light scanlines (both the standard horizontal scanlines, as well as faint vertical lines, as would be found in a phospher mask):
I think this version does a better job of maintaining fine details and really looks nice, especially on Zelda:LttP.

Next, he produced a beautiful (and easily customizable) resolution-agnostic scanline shader. In contrast with my own scanline shaders, Themaister's shader will work with any scale factor instead of having one hardcoded in. Here's how his default version looks without and with bilinear filtering (smooth video), respectively:
In addition to this default, I modified the settings to create medium and dark scanline settings, as well (each shown without and with bilinear filtering enabled, respectively):

You can download these shader's from my mediafire account. If you would like to modify the scaline shaders yourself, you can play around with these figures:
const float base_brightness = 0.95;
const vec2 sine_comp = vec2(0.05, 0.15);

Analytics Tracking Footer