Showing posts with label gameboy color. Show all posts
Showing posts with label gameboy color. Show all posts

Monday, April 6, 2026

Some Shaders I've Been Working On

“Whatever you now find weird, ugly, uncomfortable and nasty about a new medium will surely become its signature. CD distortion, the jitteriness of digital video, the crap sound of 8-bit - all of these will be cherished and emulated as soon as they can be avoided. It’s the sound of failure: so much modern art is the sound of things going out of control, of a medium pushing to its limits and breaking apart. ... The excitement of grainy film, of bleached-out black and white, is the excitement of witnessing events too momentous for the medium assigned to record them.” -Brian Eno 

I've been working on some shaders lately. 

The first one I want to talk about was inspired by some posts on the RetroArch/libretro subreddit, where a guy was using overlays (I think? might have just been photoshops) to make some really dark images of Game Boy Color games that mimicked the experience of using their technically awful front-lit LCD screens.

I never owned a GBC, and only played on a GBA very briefly in its day, but the enthusiastic response to those shots was really something, and it highlighted a significant unmet need that I had never really considered before. So, I borrowed a friend's GBA 001 and set to work on it, and here's what I came up with (as always, click to embiggen):

screenshot - presets/authentic-gbc-frontlit.slang
Rather than reinvent several wheels, I'm leaning on fishku's "authentic-gbc" LCD shader, which includes the characteristic little dog-ear on each subpixel, as well as Matt Akins lovely "pixel transparency" shader, which makes the white pixels appear transparent and adds a little drop shadow to them.

My addition darkens the image (adjustable how dark you want the ambient light), desaturates it, and then adds a point light source, the focus of which you can adjust (diffuse, like an overhead light, or more focused like a lamp or even a "worm" light attachment) and move around (by default, it's in the upper-right corner, like an overhead light). Direct light washes out whatever is under it, but indirect light fades off quickly, and some of the colors get inverted in the semi-lit area.

I also added in a "shmutz" effect using a dirty glass texture, which only really shows up when it's directly lit, along with a slight green tint that those old LCDs had under direct illumination.

There's also a "Nighttime Car Mode," which makes a bright light sweep across the screen every few seconds to simulate a car passing under streetlights in the night, which is a situation people seem to have a perverse nostalgia for.

While I was working on my shader, Matt Akins was exploring another idea that had been teased by that same redditor, of showing a rainbow pattern at certain angles due to a quirk of the GBC LCD's internal structure. He added this functionality to his pixel transparency shader, and he also submitted a patch to RetroArch to enable gyro and accelerometer control hooks to the shader backend. I was planning to work on this, too, but I'm thankful that Mr. Akins got to it first because he did a much better job than I would have.

With that in place, I added an option to control the light source using gyro control, which makes for a very uncanny gaming experience, tilting a controller to shine a virtual light source on a virtual crappy screen, but then seeing hints of rainbowing as you tilt it. Fun stuff.

I also made a modification of the 'gbc' console-border preset, which looks pretty nice, but the light source only affects the screen and would have required a lot of invasive changes to work on the border, too, so I didn't think it was worth the trouble. Ultimately, it's not my favorite, but it still works well for people who really want a border.

The other shader I've been working on is a CRT shader. Yes, another one, because there aren't enough already. This one focuses on monochrome displays, which are usually just an afterthought in CRT shaders, and monochrome modes don't usually exhibit any special characteristics vs the color-full settings. This is unfortunate, I think, because monochrome CRTs are cool devices that ruled the land for decades, even after color TVs were commonplace.

First off, monochrome CRTs don't have subpixels or masks. The entire screen surface is coated with a layer of powdered phosphor material that glows when the electron gun scans over it. Having this direct view of the beam makes the dynamic width very visible, and the beam itself has a bit of ... life to it.

I tried to capture that, and, as a result, static screenshots aren't going to look very good or capture the "magic," so I recommend trying the presets live / in person, if you have the inclination. Nevertheless, here's what it looks like:

That's the 'black and white tv' preset, which is intentionally pretty blurry, horizontally. Monochrome computer monitors could be quite sharp, though, and there's an "apple-monitor-ii" preset that handles that better:


In addition to the beam perturbations, this preset also has the scanline brightness cranked up really high, which brings in some general glow visible around the numbers, and it also makes some nice trails anywhere there's movement (courtesy of the 'glow-trails' shaders I made several years ago): 

Both of these presets include my analog service menu shader, which lets you adjust lots of physical CRT parameters, like h- and v-size, pincushioning, etc., as well as a version of crt-royale's geometry control that I isolated just for this. It allows you to tilt the monitor up/down/left/right and control the radius of its curvature, among other tweaks. I picked a really exaggerated, low-radius curvature, since these displays were often very small (sub-15 inches), but I used the pincushion control to flatten the middle out some, just as you would on such a small display.

These presets also leverage blurbusters' and Timothy Lottes' crt-beam-simulator shader whenever shader subframes are enabled, and, in addition to the motion clarity improvements, I think the flicker it introduces provides another level of verisimilitude that I wasn't able to capture properly in still shots.

The monoCRT shader also includes several different monochrome phosphor colors:

Just be sure to use integer scaling with this shader, since the scanlines look like crap otherwise. As usual, it looks better when it has more pixels to work with, and I think 5x scale is a minimum, making integer overscale on the Y axis a great way to experience these on 1080p displays. 

So that's what I've got. The 'frontlit-reflective' shader is available in handhelds/shaders, and monoCRT is available in crt/shaders, if you want to use them in your own presets. Most of the presets I've shown here (authentic-gbc-frontlit, black-and-white-tv, and apple-monitor-ii) are available in the 'presets' directory. Aside from the beam sim effect and the gyro controls, which aren't widely supported outside of RetroArch, these shaders should work fine anywhere you can load slang shaders (e.g., ares, snes9x, OpenEmu, etc.).

Monday, September 26, 2011

Pixel Shaders in Genesis, GBA, GBC Emulation

If you've looked at any of the amazing pixel shaders available for bsnes, such as the collaborative CRT shader from cgwg and DOLLS or Themaister's dot-n-bloom, you may have wanted to use them with other systems, such as Sega Genesis or Gameboy Advance. Well, now you can! Update (10/03/2011): now it works with Final Burn Alpha, as well. Update (10/5/2011): I'm adding download links for Windows binaries of the various libraries, when possible.

Themaister wrote some "hacky" wrappers around Genesis Plus GX, Visualboy Advance and Gambatte that route their APIs to match up with that of libsnes. That means any frontend for libsnes, such as Themaister's own SSNES, can now serve as a frontend for these excellent emulators. Thus, any features of the frontend, such as SSNES' real-time rewind and FFMPEG-powered video dumping capabilities, get baked in automatically. This also extends SSNES' badass GGPO-style netplay to all of these systems (where applicable, of course).

If you're using Ubuntu or another Debian-based distro, you can get precompiled binaries from my PPA repo. Other *nixes can compile them from source. The only dependencies are git (not even totally necessary if you manually download the source via http), a compiler that supports C++98 or higher (gcc-3.4 and up, IIRC) and zlib (in Debian-based distros, it's the zlib1g-dev package).

So, open a terminal and type:

For Genesis Plus GX:
git clone https://github.com/twinaphex/genesis-next
cd megadrive-next/src/libsnes
make

Download Windows libsnes-genesisplusgx binaries
(you may need to rename zlib.dll to libz-1.dll for it to work)

For Visualboy Advance (vba):
git clone git://github.com/Themaister/gba-next.git
cd trunk/platform/libsnes
make

For Gambatte:
git clone git://github.com/Themaister/gambatte-libsnes.git --branch libsnes
cd gambatte-libsnes/libgambatte/libsnes
make

For Final Burn Alpha (fba):
git clone git://github.com/twinaphex/fba-next-slim.git
cd fba-next-slim/src/burner/libsnes
make

Download Windows libsnes-fba binaries

The resulting libraries will all be called libsnes.so. In my packages, the libraries are named according to the emulator (libsnes-*.so) so you can have them all peacefully coexist.

One thing to be aware of: SSNES-Phoenix's file browser will filter out non-SNES extensions, so you'll have to manually type the filenames unless/until Themaister does anything about it.

Screenshots (dot-n-bloom shader is used for the GBC and GBA screenshots, CRT is used for Genesis and FBA):


Analytics Tracking Footer