Yet, another CRT Shader

The screen shows upside down with this.

With bsnes_accuracy core I can’t really run this or the previous (long) version without heavy stutter (just checked and performance core is fine, : / ), I have many issues with this core and shaders, don’t know why.

It’s a pity you don’t want to add bloom, I was really waiting for that down the road. I think curve screen is not that important but bloom gives that nice magic touch that makes the image really look like something analog and not digital processed.

Ok, I upgraded the horizontal interpolation algorithm. The last version was using a standard Cubic. Now I’m using a Cubic Spline. With this, the pixel transitions are more smooth while the overall sharpness is increased!

This is a comparison shot, look at the wings:

I just updated RA repository with this new version and a new one called crt-hyllian-lq.cg, which is intended for low end devices.

The cgps mentioned earlier were uploaded too. They’re inside cgp folder.

I think this shader started going downhill when you accepted the suggestion of horizontal sharpening (back in page 3 IIRC), I think v6 or thereabouts. Interpolation is about blending, so I would rather have a soft look than a very sharp one where pixels just converted into dots. I can see that gradation is better with cubic spline than with plain cubic (look those cubes!) but the gained sharpness is unfitting moreover when bloom won’t be included in your todo list.

For subtle changes I recommend you some pages like check2pic or screenshot comparison. http://screenshotcomparison.com/comparison/71774

I think you’re a bit misguided here. The sharpening sugestion was included as an option and is OFF by default!! So, I don’t get your complaining about it.

I see that you’re a bloom lover. If I find an easy and not bloated implementation, I might add it in the shader as an option (OFF by default) in future releases, because not everyone like it. For now, I don’t have anything about it here. It should be a completely independent shader to be applied as a second pass, I think.

Thanks for the screen comparison site, it is very good indeed! I’ll use it in the future.

Thank you Hyllian, I want you to check if these screens are fine. Since (virtual) version 10 I noticed a change where there seems to be some ringing for better definition, on last version the effect was softened but still present, is this how it should look? (reading green letters here):

v9 vs v10 vs v11

Interpolation is set to nearest on the cgp.

edit: Well this seems to be a bug on retroarch, I switched to performance core because on accuracy many shaders were giving me issues (stuttering), the thing is that on performance core rendering is wrong (as shown above), I just went back to accuracy core and it shows fine… I hate when unexplained things like these happen : /

I like the cubic spline better, personally.

bsnes-accuracy always has a horizontal resolution of 512, while performance is usually 256 (except when required). The doubled resolution is probably why you’re getting different performance between the two cores.

I hadn’t seen that comparison site before. Very handy!

There are two explanations for these three diferent screens:

1- The first image (V9) shows that you are feeding the filter with an image using 2 times the horizontal native resolution. This can be achieved by two ways: the first one is how hunterk explained, the bsnes acuracy provides 512 horizontally. The other one is enabling the SHARPER option in the shader, because it provides 2x resolution horizontally to feed the filter.

2- The V10 and V11 images are correct. In V11 I fixed a small bug that upgraded pixel transition. That’s why the border is better in V11. By the way, V12 improved even more the pixel transition with the introduction of Cubic Spline, so it’s the best now.

Yes, it does. Thank you.

This cubic spline is making a good job. Now a low resolution game such as the GBA is on the level of crispness of lanczo. I still stay with CGWG for curvature and linear interpolation but your shader has its advantages for sure.

It’s fast! made some tests with sf2ce on Mame: -crt CGWG flat no interpolation can speed up to 780% -crt CGWG with 3x oversampling to have more precise scanlines (more like your shader) is around 500% -crt Hyllian around 1100%

But integer scale is a must. CGWG shader scales better, particularly with the gaussian beam profile.

Yes, cgwg’s is more accuracy focused while mine is more empyrically made. My eyes are my guide. =D I’m using the philosophy of “the ends justify the means”, and his approach is more like “there’s only one right path to a perfect end”.

I love cgwg’ shader too. The only thing that limits its usage by me is that it doesn’t run fullspeed in my PS3. And I always prefer its flat and single shader over the other multipasses versions or the curvature ones.

I use crt-interlaced-halation for MAME, I don’t know why but it is the few cores I can use this shader with. And arcade + bloom is a must IMO.

mmmh, and I have been all this time thinking the v9 was the correct one. I was using bsnes_accuracy for the timing, I want perfect timing while playing for the same reasons I check on vsync. Guess I will have to switch to bsnes_balanced but it’s a pity we can’t pair both things.

What happens if you use bsnes_accuracy core with the V12 and enable SHARPER option and use the value 0.5 for SHARPNESS?

Maybe it’ll feed the filter with 256 samples instead 512…

[quote=“Hyllian”]

What happens if you use bsnes_accuracy core with the V12 and enable SHARPER option and use the value 0.5 for SHARPNESS?

Maybe it’ll feed the filter with 256 samples instead 512…[/quote]

Yes, it worked! so sharpness 0.5 implies half sharpness (blur?).

No. This particular sharpness algorithm I’ve got from other shader is just a hack. It multiplies the horizontal texture resolution by a value (the default value is 2.0) so that the filter is feed with more samples than in a normal usage. When you do this, the cubic interpolation sharpen the result. As bsnes-accuracy core already does this by default, you can revert it by using a 0.5 multiplier, bring the horizontal resolution back to 256 samples. You’re just reversing what the core does to its output.

The new Cubic Spline interpolation looks fantastic (much better for any resolution really). That said, I’ve been noticing that your shader seems to add some sort of inverted image shifted 1 pixel to the right, and another one shifted 1 pixel to the left (the result being a more contrasted image) : But in some screens, the result is not as clean as I think it should be (and doesn’t really work as a contrasting effect) : (see the N or the I of KONAMI)

Although I have no idea what I’m doing, I’ve been changing some values in your code to obtain a cleaner image (horizontally) :

float3 c10 = tex2D(s_p, tc ).xyz;
/* instead of :
float3 c10 = tex2D(s_p, tc - dx).xyz;
*/

And this :

float3 c13 = tex2D(s_p, tc + 1.0*dx).xyz;
/* instead of :
float3 c13 = tex2D(s_p, tc + 2.0*dx).xyz;
*/

I loose some contrast, but the result is really clean :

Nevertheless I feel like I’m loosing something in the process. Is there a better way to avoid this ?

Leos, I need to reproduce this supposed problem here first to understand what you’re talking. So, I need some things:

1- Provide an easy to find snes game (just the name) that presents the problem in its first screens; 2- Post at pastebin the shader you’re using to show the problem; 3- Post at pastebin the modified shader you made to solve the problem.

With these three things I can analyse the case properly.

Tiny Toon Adventures - Buster Busts Loose! (USA) (I can PM you a link if you don’t find it) Press start 3 times and you should see the title screen without any demo starting :

I use the current v12 : http://pastebin.com/cL4MSZKg

result : watch the blue ears, when 3 pixels of the same color (horizontally contiguous) are framed by black pixels, the shader renders the middle pixel less bright than the others, and that can look strange in some screens like I showed you before on the Konami logo of gradius 2 (for nes).

Here it is : (see line 137 and 140) http://pastebin.com/zJyhaQ6B

Now the blue pixels are of the same blue (but then at the same time it looks a bit flat) :

Tks, Leos. I’ll look at it.

Leos, that’s called ringing, it’s because overshoot or excess of sharpening. It looks “good” because it kinda resembles “bloom”. I know nothing about programming but I do some image processing and scripting with avisynth. Maybe that’s caused due to negative lobes on multi spline scalers.

On anothee note I thought maybe that I should use bsnes_balanced because although I might have solved the issue for this shader by tweaking “sharpness”, maybe I won’t have the same luck with other filters.

Ok. I tested here and I agree with Dogway. It’s a very small ring artifact from the cubic interpolation.

I can’t fix that. The only way would be changing the algorithm. I verified the standard cubic I was using before the spline, in other versions, and it produces the same artifact. So it wan’t introduced in the last version, it was there since I introduced cubic.

Leos, your solution destroys the cubic interpolation, because reduces the samples from 4 to only 2. And it produces many other artifacts and bad image quality. It’s much better having a small ring artifact that appear in particular spots than a whole screen ruined in all games, imo.

So, it’ll stays as is.