Bsnes mercury - gamma ramp option?

Hi, was checking github source and noticed that the “old” bsnes NTSC gamma ramp option is still in the source code but deactivated.

https://raw.githubusercontent.com/libretro/bsnes-mercury/master/sfc/system/video.cpp

line 26

    if(mode == Emulator::Interface::PaletteMode::Emulation) {
      r = gamma_ramp[r];
      g = gamma_ramp[g];
      b = gamma_ramp[b];
    } else {
      r = image::normalize(r, 5, 8);
      g = image::normalize(g, 5, 8);
      b = image::normalize(b, 5, 8);
    }

It can be activated here: https://raw.githubusercontent.com/libretro/bsnes-mercury/4a94095e4f9f5e54739dd9d00b48a81c5b4ddd87/target-libretro/libretro.cpp

line 448

struct Interface : public SuperFamicom::Interface {
  SuperFamicomCartridge::Mode mode;

  Interface();

  void init() {
     SuperFamicom::video.generate_palette(Emulator::Interface::PaletteMode::Standard);
     // ==> Emulator::Interface::PaletteMode::Emulation
  }
};

I think this would be good because I tried using the image shaders (saturation, luminance, contrast, gamma) but no combination seems to get a “nice” balance with 240p test suite: pluge, all color bar tests, grey ramp. They either wash out, overbend, over-heat colors or crush too many blacks, whites together.

Compared images to bsnes-plus 0.73, which has the gamma ramp option. It’s more painless and looks decently nice.

Can’t compile this to test myself. I’d love to tear apart the libretro binary to try and find the switch to playtest but can’t figure out where it lives either.

Thanks for any help

1 Like

I put in a PR to add it. We’ll see what Alcaro has to say about it.

1 Like

Awesome! It’s available in the online updater. Thank you for getting it up and working so quickly.

1 Like

Here is a LUT+Preset for LUT shader:

BSNES LUT:

Presets: bsnes.cgp / bsnes.glsl / bsnes.slang

1 Like

Thank you. This reshade palette matches the bsnes one and can now be used with any snes emulator. :slight_smile:

I added these to the repos, as well.

You’re welcome :slight_smile:

Actually, the LUT itself matches 1:1 the output of bsnes gamma-ramp option only if you don’t use any interpolation on LUT shader. This is not possible with the current implementation of LUT shader, as it forces interpolation on blue channel, so you have to edit it a little bit in order to get it to actually “match”. But maybe its not worth it as the output is so close that probably nobody would notice the difference.

Can anyone please explain why one would want to use a different gamma ramp than what the native RGB outputs?
Say for example I use a hardware SNES and connect it in RGB to a Sony BVM, where does this gamma ramp come into play?

To me it looks too dark and crushes the black shades, look at the background here for example, it’s from the new bsnes-mercury option:

It seems it was actually from Overload’s Super Sleuth emulator, but byuu (and apparently others) really liked it, so he copied it. It amplifies the gamma more on darker colors and less on lighter/brighter colors. See this old zboard thread for history.

I’ve never much cared for it, personally, for the same reasons you mentioned but it does make the image look more vibrant.

I have tested on a properly calibrated Sony Trinitron 29" in 15kHz RGB and the gamma ramp looks nothing like a real CRT.
It is hard to capture the huge contrast ratio of a CRT with a smartphone camera but these pictures will clearly show that the black shades are not crushed like in the “gamma ramp” tweak, but instead look VERY similar on what you see on a calibrated LCD monitor but with the pretty scanlines and huge contrast ratio.

Face it, no gamma ramp tweak can emulate a CRT.


I’m with you, nothing beats a CRT. The pictures don’t make the justice.

Nevertheless, it’s always nice to have options.

(see byuu’s pictures - snes, gba, gbc)

Zelda3 plain rgb pictures (storm) are just too “grey washed” for me. Same in-doors. And in-game dungeons look too “bright” also at half-light. Playing this on a very bright (cheap) monitor so maybe that’s why heavy dark and red tint appeals more. And some other games where it contrasts some dark / light areas like arena floodlights and such. Using the bsnes gamma ramp is a quick fast-food option for specific games.

For Lost Vikings pic, I’d go with normal RGB with maybe some normal gamma adjustment; definitely not the ramp. :lol:

No offense taken at all to anyone above. I always need more opinions about what’s decently right or very blindingly wrong. Never got a chance to grow up with real CRTs or equivalent. I don’t need anything close to perfection though. Just something that doesn’t trigger my stop-and-stare at screen mentality. :smiley:

But thanks again! I like options. Lots of them. Always tweaking per game really.

Oh man… you’ve missed way more than CRTs.
I’m an '86 model, and a child of the 90s.
No cellphones, no internet, Nes, Sega, Snes, and actually playing outside climbing trees and rooftops, in the evening it was Fresh Prince of Bel-Air or Married with Children.
Childhood in the 90s was pure and carefree, I damn well miss it. :sob: Good times I tell you… :slightly_smiling_face:

As for CRT look on an LCD, go with CRT-Royale shader, trust me and many other Trinitron owners, I have compared it closely to the CRT and it is so very close to the real deal it’s amazing.

1 Like

Man, the only thing you missed was Ninja Turtles, and you’d spelt my childhood!

Apologizing for the major grave-dig, but I registered just to respond to a major oversight you made since this thread is the top result on some search engines when searching for “old ntsc gamma SNES”.

The issue is that you used a Trinitron.

As someone that also used a Trinitron all the way from 2000 to 2013 as my primary TV, you missed a key point that Trinitron TVs use the same (or very similar) gamma ramp that HDTVs use. So while they are clearer and brighter than previous CRTs and are quite possibly the perfect display for “480p” consoles like the DreamCast, GameCube, Wii, etc, the gamma ramp is actually incorrect for most older 90s retro games.

This was particularly noticeable actually in the game BattleTanx: Global Assault (the N64 version specifically) on night levels which is possibly one of the only 3D game examples of this gamma discrepancy. On a Trinitron or any HDTV, the distance just looks like a murky grey fog but, with an older non-Trinitron CRT TV (or an HDTV that simulates that older gamma ramp when using composite input like my Toshiba L1350U does), that same murky grey fog now actually just looks like distant darkness and makes much more visually and artistically.

And double-apologies for the double-post, but it seems I’m not able to edit my post (perhaps it times out after 24 hours?)

Regardless, I found a forum thread covering the subject of gamma being different on older CRTs compared to modern HDTVs and the like, and there’s even at least one poster that was describing exactly the same pitfall I was saying where the gamma on their Trinitron basically looked the same as a modern HDTV:

https://www.atari-forum.com/viewtopic.php?t=37519