2xBRZ shader for RetroArch?

I have a bit of a conundrum that I’ve been stuck with for the last couple years. Ever since I discovered the xBRZ filter, it has become my definitive shader that I prefer to use for all my retro pixel art games. I think it does the best job of smoothing out the pixels to give them an HD-looking makeover while maintaining a reasonable sharpness and consistency.

Problem is, my preferred setting for xBRZ is the fixed 2x preset as featured in SNES9X and VBAM, but my preferred emulator for my SNES titles is BSNES for the superior color contrast, accuracy, and sound quality. By default, BSNES emulator only comes with the freescale version of the xBRZ filter, which renders at something that looks more closely like the 4x setting on the standard version of xBRZ. It’s too powerful for my taste, smoothing out the pixels too much and distorting the game’s original art style.

I later learned that this freescale version can be easily modified to limit the scaling factor on it, but even after applying these changes, it still doesn’t look right. It seems to be using a fundamentally different algorithm from the fixed 2x - 6x preset options that we see in SNES9X and VBAM. So, that’s when I decided to try looking into RetroArch. While I was initially ecstatic to find that it has more fixed scaling xBRZ options than standalone BSNES, they still are only limited to 4x - 6x, for some reason missing 2x and 3x. I am not sure why these two are omitted, as to me they are vastly preferred for improving the picture quality of 16-bit era games.

I have tried desperately to examine the code over and over again to see if there were some easy tweaks I could make in order to say, re-adapt the 4xBRZ filter into 2x by simply flipping a few values around and changing some lines of code, but after careful combing through it, I still just don’t understand nearly enough of how it works to make the modifications. I would be eternally grateful if anyone could provide a proper 2xBRZ option for RetroArch; one that isn’t just a tweak of the freescale version, or if they could point me in the right directions of how to achieve this myself. Though I must warn you regarding the latter option, my brain has already melted trying to understand this code, so if it requires any extensive knowledge of how the smoothing algorithm works I’m probably not going to be able to follow it. I’m just not at that level yet.

1 Like

Wow! It seems like you’re working too hard. Try this instead:

Just use my “CyberLab__Composite-Sharp__PVM-Edition”, “CyberLab_Computer_Monitor-Sharp_ADV” or “Cyberlab__RGB-Sharp__PVM-EDITION__ADV” presets. I think you’ll find that at least one of those has the right balance of smoothing without being excessive that you’re looking for.

You can even try my new CyberLab__Composite-Pure__Soqueroeu-TV_Special_Edition_SNES_ADV preset + Blargg_NTSC_TurboDuo_SNES_PSX_Composite_CyberLab_Special_Edition video filter which is also included in my preset package.

I appreciate the help, though I could not get these shaders to run. It would just crash back to desktop. I should note that I’m using a 10+ year old gaming PC that I have converted into a RetroArch media center for my living room TV. Though it does have a GTX 660 TI running in it, the processor is a pretty anemic 1st gen core i7 by today’s standards, but that’s all I need it to be for my needs on this device.

I should also mention that I have very little regard for nostalgia. I play these retro games because I think their gameplay still holds up and is worth revisiting, but I have no interest for replicating the glory days of CRTs and scanlines. I just like to clean up the visuals for modern displays as much as possible, and 2xBRZ is all I really need for that. These shaders look really nice for what they do, but seem a bit over-designed for my needs from what I’ve seen of the screenshots.

The frustrating thing for me is, I know the code is already out there and written. It’s just not in the glsl or slang format for RetroArch.

Does RetroArch still accept .CG? Because I see there is already a 2xBRZ script written in it that I presume used to work on older versions of RetroArch:

1 Like

Cg support isn’t included in recent releases, but I went ahead and ported the 2x version to slang: https://github.com/libretro/slang-shaders/blob/master/xbrz/shaders/2xbrz.slang

It should be fetch-able via the online updater soon (probably take a few hours).

5 Likes

With a little patience and a few settings adjustments you might be able to get HSM Mega Bezel Reflection Shader to run on your system and adjust the presets to your liking.

There’s an alternative upscaling shader called ScaleFX that’s included in HSM Mega Bezel Reflection Shader that isn’t as harsh as xBR.

I’ve never used it standone but I think you might like it. It does similar things to xBR just in a better way in my opinion.

If you’re interested and have the time we can still try to see why HSM Mega Bezel Reflection Shader isn’t loading for you for curiosity sake. It’s always nice to get additional hardware compatibility info to help with its development and improvement. If so, can you post a log?

I REALLY appreciate your help with this. Unfortunately, after trying out the updated slang shaders it still seems to be different from the algorithm used in standalone SNES9X and VBAM. Take a look at these screenshots.

Here is SNES9X standalone with 2xBRZ shader:

And here is RetroArch running its own version of 2xBRZ:

You can see that with RetroArch there is a blurring effect over everything that greatly diminishes its sharpness (you might need to open the image in a full size tab in order to see the difference). Almost as if a bilinear filter or something is running on top of it as well?

This gives me an idea. Might see if I can modify the slangp file to turn off a linear filter setting if present and see if that’s the culprit.

Thanks again, Cyber. I might check out that ScaleFX shader as well and compare it to xBRZ.

As it stands right now though, I just got RetroArch up and running for the first time with my media center machine and I want to get it in working order with the basics first before I fiddle around with any more experimentation and troubleshooting. I don’t even know where the logs are located and how to generate them, and I have to navigate everything with a controller which is a bit cumbersome over a mouse / keyboard setup whenever I have to switch back to my Windows desktop, so the less tinkering with that the better.

1 Like

Yeah, that’s exactly what’s going on. The 2xbrz pass is followed by a stock pass with the filter set to “linear”. If you change that to “nearest” and apply settings (you might have to do it 2x to get it to stick), it should look chunkier.

3 Likes

I got it! I just removed the second shader pass entirely which was the one that included the linear filter, and now it runs exactly as I want it!

You just helped me solve a multi-year long frustration. Now I don’t have to compromise between the accuracy of BSNES and the quality of xBRZ. Thank you.

1 Like

heh, yeah, that works, too. I’m glad that got you fixed up.

2 Likes

On a somewhat unrelated note, one other thing I wanted to look into was stretching the image to always be at full height. Sometimes SNES titles have a black bar across the bottom during certain segments, likely due to an aspect ratio shift I’m guessing, but I’d like to just stretch the image as much as possible anyway while maintaining aspect ratio, even if the pixels may not always perfectly line up. Is that a feasible option, or are these emulators just not capable of intelligently adjusting that?

Or at the very least, can the viewport be centered to the middle of the screen rather than having a black bar only across the bottom?

Edit: Also-also, is there any meaningful difference between “gl” and “glcore” for the driver? Only difference I noticed was that glcore seems to support slang while gl doesn’t, but aren’t they both just implementations of OpenGL?

gl is “legacy” OpenGL (v2.0+) while glcore is “modern” OpenGL (v3.0+), and yes, the most obvious difference is which kind of shaders work with them. Otherwise, they should be largely interchangeable on modern GPUs.

The black bars are typically part of the image. Most cores will have a “crop overscan” setting in quick menu > options, which will usually take care of it for the most part. Another option that works well on 1080p screens is to go to settings > video > scaling and turn on integer scaling and “overscale”, which will bump it up to 5x scale. This means some of the image bleeds off of the visible screen, but it all stays well within the “safe” area that Nintendo recommended developers use to accommodate the differing levels of overscan that individual televisions would have.

4 Likes