Cropping black borders?

I’m mostly trying out arcade games on the Flycast core, but tried Mame core as well, and I’m being faced with variable proportions of black borders on all four sides in almost every game. Some have them on top and bottom only. Some have a thicker top border than bottom. Same for the sides. All sorts of combinations. The same games on Mame(emulator, not core) don’t have this issue at all.

Not just Mame but pretty much every emulator out there has a “fit to screen” and/or “stretched” option available for different aspect ratios which extends it to fit your screen while keeping the aspect ratio intact. And most importantly, no black borders. Why doesn’t Retroarch have this super convenient and extremely important option?

Anyway, how do I remove these borders? I’m using a custom shader preset and it doesn’t have any option like that. I searched on google and found that there is an image-adjustment shader that has the option to crop. I found it in my shaders, but it doesn’t have the cropping option.

Vulkan
Integer scaling: Off
Aspect ratio: Core provided(tried 4:3 as well)

can you post some screenshots and examples?

Top and bottom(uneven)

Right and bottom

Top and bottom(even)

All four sides

These are just four of the many different variations, as I’ve stated before.

I can confirm the SFIII (DC) one, as it looks the same for me using core provided screen and no integer scaling. Only other game that I have tried is Fist of the North Star (Atomiswave), and it didn’t produce any black bars. At first I thought maybe it was something with Capcom games, then @QQQ posted KOF Neowave with some as well.

It’s not a huge surprise for console games, since they often relied on overscan to hide that sort of thing. Arcade games are usually more consistent, though.

1 Like

They run fine in their respective standalone emulators though.

And as I described before, the same thing happens in Mame arcade games too on Retroarch. Two of the above (KoF neowave and SF Alpha 3) are arcade versions.

The important thing is… how do I crop these?

If you have a fairly beefy PC. (GPU is the most important.) The Mega Bezel shader has built in cropping tools.

There are also an astounding number of parameters you can use to tweak just about anything else.

Thank you for pointing me to this HSM shader pack. Actually I already knew about it and even tried a few but they take quite a bit of time to load. During this time Retroarch gets stuck in a frozen state.

I’m new to Retroarch so that’s another thing. I’m trying to keep it as simple as possible. I’ve been using a simple custom made preset that I found online. It doesn’t have cropping though and that’s the real problem. If only there was a simple shader that could just do that. I’m quite surprised that even the image-adjustment shader does not have that ability.

1 Like

Double check that you are using the Vulkan video driver (Or glcore).

If it freezes you are most likely using DirectX.

Do you have “Crop Overscan” on in the RA Video Scaling settings? It might help quite a bit.

It does. Try the “overscan %” parameters: https://github.com/libretro/slang-shaders/blob/master/misc/image-adjustment.slang#L39

Yes I have both Vulkan and Crop Overscan.

Already tried. What it does is remove the borders equally from opposite sides which is only good for those games where the borders are even on both sides.

What’s needed here is an independent crop option for each individual side.

Here is another example of an arcade game with black borders

Now it seems I can use image-adjustment with it since the borders on both sides seem to be even. But there is another problem. If I try to use image-adjustment using “load”, it doesn’t show up in the slang shaders list. I know it’s in the “misc” folder but Retroarch doesn’t show it. How am I supposed to use it? I don’t remember how the last time it showed up. I even restarted Retroarch but it still doesn’t show up.

it doesn’t have a preset, so you can’t use the ‘load’ option, you have to load it manually by incrementing the number of passes by 1, then go down to where it says ‘pass [X] N/A’, navigate to it in the ‘misc’ directory and then hit ‘apply’ in the shader menu.

1 Like

Thanks it’s loaded now.

Now I have two questions:

  1. How do I use it with my custom preset?

I loaded the preset after but it overwrote the shader. I loaded the preset first then added a 6th shader pass(the preset has 5 passes). The shader got added at the very last of the chain but it messed up the image. So how do I go about it?

  1. What’s Shader #0 Filter and Shader #0 Scale?

The preset I’m using was made by someone and it shows that all “Shader # Filter” values in it are “linear” . When I tried to make the same preset on my own, I added the 4 shaders that it’s composed of, but I couldn’t change the “Shader # Filter” values. They are all set to “default”. So how can I change these filter and scale values?

There are a couple of ways to handle it, but unfortunately, you’ll have to get your hands a little dirty with a text editor for either one. In both cases, open the preset file in your text editor (make a backup of it first, just in case you fuck it up somehow) and look for the ‘shaders = X’ line at the top and bump it by 1, then:

  1. (the better way) put image-adjustment as shader 0 and bump the rest of the passes down 1. If there are a lot of passes, the easiest way to do that is go down to the bottom and find-and-replace for the last pass number followed by a space (e.g., 12 ) and replace it for the next highest number followed by a space (e.g., 13 ), and then work your way backward (11 -> 12, 10 -> 11, 9 -> 10, … 2 -> 3, 1 -> 2, 0 -> 1). You don’t need to worry about any of the other metadata for the image-adjustment pass in this case, just the path to the shader itself.

  2. (the faster/easier way) scroll down to the bottom of the file and change the scale type for the last pass to ‘viewport’. Then, add another pass after it that points to the image-adjustment shader. You don’t need to worry about the other metadata (filter, scale type, etc.).

I don’t understand any of these.

In the first one, am I supposed to do it in the preset text file? I did add image-adjustment as

shader0 = “shaders_slang/misc/image-adjustment.slang”

I then changed all shader numbers, but it just messed up the whole image when I loaded it in Retroarch.

In the second one, am I supposed to do it in Retroarch? As I stated before, I can’t change either Scale of any pass nor Filter. When I look in the text file of preset there is no scale setting.

The preset I’m using has many lines but only 5 passes. I think I’ll just add the link to that preset here so you can see how it is written:

How do you add image-adjustment to this?

In the first one, you need to change all of the numbers, which tell which pass the metadata applies to (e.g., ntsc-pass1 needs float_framebuffer to be true or your whole image turns magenta). So, if it was pass 0 and you moved it to pass 1, all of the foo0 = “bar” lines need to change to foo1 = “bar” instead.

Ok this is how I applied it. Is it ok?

Though it’s pretty tedious, time consuming and prone to errors. Like imagine if there were 30 shaders or something this would be a nightmare.

What about the second one(the faster and easier way)? As you can now see there is no scale type setting at the bottom of the file that I can change to viewport. So how to do it?


And also, again my other question: What are these Shader Filter and Shader Scale values shown in each pass? Where can I find information about what they do and how to change them and what values they can be changed to? Because apparently I can’t change them from within Retroarch. I click on them and nothing happens.

You can change them in RetroArch by pressing left/right on the dpad/arrows. Filter is either “linear”, which means it uses the GPU’s built-in bilinear filtering hardware (blurry but consistent) or “nearest,” which makes the image sharp but prone to uneven pixels. Some shaders require one or the other but many don’t care, hence the “don’t care” setting being the default and what is used if nothing is specified.

There are a few different scale types, which are used to calculate the output size of the framebuffer: ‘source’, which is based on the size of the input framebuffer (the most common), ‘viewport’, which is based on the size of the current window (or your monitor in fullscreen), or ‘absolute’, which is a specific number of pixels (e.g., 240). If you need to add a scale type to a pass and there isn’t one there already, you can just add that line: scale_typeX = “whatever”. ‘Source’ is the default for all passes except the final pass, which defaults to viewport (to stretch the image to fit the screen).

If you specify a scale_type, it will assume a scale of 1.0 if you don’t manually specify one, which brings us to scale: Scale is the scale factor applied the output framebuffer. If you have a shader that needs to function at exactly, say, 2x output (such as hq2x), you can set that there.

So, with the second strategy, you’re basically recreating the last pass’ automatic behavior in the second-to-last pass (i.e., so the effect looks right) and then slapping the image-adjustment shader on top to modify it. This may not be what you want: for example if you have a CRT curvature effect, your cropping won’t crop the game, it’ll crop the virtual screen bubble.

Note: this information is all contained in the slang shader spec document, which is available from the repo’s README.

1 Like