CRT Scanline shader for SNES Classic Mini?

If you look on the pillar of the red building the bottom half has uneven scanlines every other scanline or so yet the top half seems to be fine!..

It looks more prominent on my 42 LCD screen but you get the general idea from that screen shot

EDIT: Also if i change the Aspect ratio Height to 672 then you can see the difference from the bottom half of the screen compared to the top…

1 Like

Have you tried not using a custom aspect ratio and just using regular ol’ scale-to-fit with core-provided aspect?

Okay I have a few questions for you"

(1) Why are your images 2560x1440? Just because you’re viewing a video at your desktop resolution? What was the video captured with? And what resolution was the capture done?

(2) Is your TV 1080p? Because the snes classic outputs 720p only, so the scanlines will get applied to the 720p image and then upscaled to 1080p by your TV no matter what.

So it isn’t really possible to have “integer scaling” unless you plug an snes classic into a 4k tv (720 goes into 2160 evenly). And this means that there is probably no way to get perfect scanlines on a 1080p tv even with the integer scaling options of retroarch or writing the shader to only to integer scaling. We’re stuck with some scaling no matter what and that will mess with the scanlines to some extent.

But I’ll set my rpi to output 720p and try to get things as nice as possible this evening. I just spent a while making the shader do integer scaling before realizing that this won’t fix our issues at all because 1080p sets are the target.

1 Like

No i didnt, ill give that a go.

Ok,

1.Yeah by desktop res is 1440p

2.I captured at 720p

3.My TV im viewing on is indeed 1080p.

Bit odd that is only appears to be displaying uneven scanlines on the bottom half of the screen though

Hi, after setting my rpi3 to output 720p I found that it’s pretty tough to come up with something that looks good all of the time. So I took a shot at writing a shader that scales the image up to the largest integer that fits in 720P (or whatever the native res is), centers the image there and then applies a more basic scanline effect. The advantage of this is that the 720P output just won’t have uneven scanlines. It can’t unless I just messed up. Which is possible because I had a heck of a time actually getting this to work properly.

Unfortunately it isn’t faster than the old shader. Which means we need to test the speed again. And good output depends on your TV doing decent scaling to 1080p. And unless the game resolution is a divisor of 720 then you’ll get an image that isn’t full height. But I think this is the best chance at something that looks generally good.

You can grab the shader and a preset file here:

The preset GLSLP goes in the parent folder and the GLSL goes in the shader subfolder (the normal case for retroarch shaders…).

Let me know if this works and especially if there is weird output (size/position of the game). And what the speed is. Sadly it could be slow…

This is what it’s supposed to do:

EDIT: and as soon as I looked at the post I realized that the image won’t be quite centered horizontally because I didn’t account for the aspect ratio of the game… oh well

It sounds like the number precision issue I described here.

Thanks ill give that a go this evening.

It makes me wonder what technique Nintendo used themselves to get even scanlines then, it doesnt look that great to be honest, their scanlines are way too light and not defined enough but they are even so not sure if they just used an overlay of sorts or shader

Ok just tested the lastest shader and the scanlines are now even and speed is 100%. Testing Batman and the screen was shifted down so i had to go into the video settings and alter the Aspect ratio Y Position back to 0 so the screen was centered.

Just to confirm the correct locations to put the 2 files. The file structure on the SNES classic for the main shader folder is…

/etc/libretro/shaders

so i should place ‘ZFAST_CRT_SHADER_SCALING.glslp’ in that location and do i then need to make another folder named ‘shaders’ so…

/etc/libretro/shaders/shaders

and place ‘ZFAST_CRT_SHADER_SCALING.glsl’ in that folder?

Also i have notice that, Dark Pixel Brightness Boost parameter isnt in your shader setting anymore is there a reason for that?

The ‘ZFAST_CRT_SHADER_SCALING.glslp’ file contains a reference to the ‘ZFAST_CRT_SHADER_SCALING.glsl’ file in subfolder called shaders. The only retroarch install I have is what came with retropie and they have GLSLP files in a ‘shaders’ folder and then GLSL files in a subfolder of that called shaders. So yes, there is a shaders/shaders folder! It seems odd, but I just shrugged my shoulders and did what they did. If that’s not how it is in the snes classic retroarch then I don’t know. Of course, you don’t really need the GLSLP. It just sets the ‘Linear Filtering’ and ‘Don’t Care’ options for filtering and scale.

Regarding size options and stuff in the ‘Video’ section of the settings: I’m assuming that you are at the defaults. So if you set ‘Aspect Ratio’ to ‘Config’ you should get a correct picture. If that’s set, then retroarch should ignore the ‘Custom Aspect Ratio’ Position/Size settings.

And yes the settings are different now. This is a significantly different shader now! You set the ‘Scanline Amount (High)’ to however dark you want the scanlines for light colors and then you set ‘Scanline Multiplier (Low)’ afterwards to however dark you want the scanlines for darker colors.

If the picture is a bit too dark after you set the scanlines, you can turn down the ‘Fake CRT Gamma Correction’ although this won’t make too much of a difference.

1 Like

Would it be possible to make a version with curvate support or will that put the shader back to crt-pi performance?

So if you want even scanlines across light and dark colours what does the difference need to be between the 2 values, say for example I had the scanline amount (low) set to 4.0 what would the high setting need to be?

There are two ways:

If you want even scanlines AND the mask effect to be applied equally to bright and dark sections of the image, then you can set the Mask/Scanline Fade to 0.0. Then the scanlines and mask will both be applied as if all pixels were dark.

Or, if you still want the mask to fade out, but the scanlines to be equal darkness everywhere, then you would set the “Scaline Multiplier (Low)” to 1.0. Then the “Scanline Amount (High)” will control the scanline darkness for all pixels.

Excellent!

Do you mind if i let people know about your shader on the NeoGaf Mini SNES Hacking thread or are you still going to tweak it some more before proper release?

I don’t mind if you tell them. But I’m still going to fix up the LCD style shader with the proper retroarch syntax/parameter stuff and see if I can actually figure out how to center the games properly. I think it may be retroarch overscan options that are the issue…

So anyone that grabs the shader now won’t get the “Final” version. Not that the shaders I’ll post later tonight will actually be final and bug free.

But on a happy note, I actually just bought an SNES Classic edition. My Target had five or so out and said that they put them out less than an hour before I got there. So I can try out my shaders in real time instead of making you do it! At least, once I hack it and figure out where the shaders go…

Awesome stuff, its super simple to hack the thing so you should have any issues

Hello,

I’ll be at work for the next several hours after this post, but before I go here is the current (beta!) iteration of my shader along with at retroarch.cfg.

Here you go: https://drive.google.com/file/d/0B5_cUiAJwMMvaERtUFl2aWtDbkE/view?usp=sharing

I haven’t tested this much, but I’m posting it now anyway…

The “retroarch.cfg” files goes on the snes classic in “/etc/libretro/” The “ZFAST_CRT_SHADER_SCALING.glslp” files goes on the snes classic in “/etc/libretro/shaders” The “ZFAST_CRT_SHADER_SCALING.glsl” files goes on the snes classic in “/etc/libretro/shaders”

The reason I’m posting the retroarch.cfg is because the built-in retroarch shader had an scanline overlay and was set to integer scaling with custom viewport/aspect ratio settings. My shader wasn’t made with this in mind, so I’m just attaching my config so that the settings should be correct. Keep in mind though that this is still pretty much untested for now since I’ve only had my snes classic for a couple of hours…

Ok have just tried your latest beta but have noticed there appears to be a faint line running down the screen on the right hand side about 2 inches in from the edge of the game screen

Yes. That line appears to be from the limited precision of the mali gpu that davej mentioned. That’s what I’m trying to get rid of now. It wasn’t visible the way the shader was before because the location of the line was to the right of the game screen before I tried to center it. For the moment all you can do is set “Mask Effect Amount” to 0.0. I tried a bunch of things after work last night to try to work around the issue but so far I haven’t been able to. But I’m still working on it. :slight_smile:

EDIT: I fudged the mask calculation so that the default mask works. The coarser 3 pixel mask still has issues. But here is the version I have now: https://drive.google.com/file/d/0B5_cUiAJwMMvZnR2TWR2VGRLSkk/view?usp=sharing

Ok ill do that for the time being.

Quick question about RetroArchs key combinations, im wanting to set a key config for exiting Retroarch, so when i press L+R+Select+Start it quits back to the SNES Classic menu. I know the button numbers for these buttons in RA is 4+5+8+9 but im not sure how i enter these in the Retroarch.cfg file. Do i need to just add them to the line for Exiting RA with a space between each number as im guessing i cant add a ‘+’ between each number??

If it’s through RetroArch and not the SNES Classic’s menu, you can’t enter arbitrary combos into the cfg, you have to select them from the hardcoded options in settings > input > menu toggle gamepad combo