Yet, another CRT Shader

Might it not be a good idea to also include an option to disable the phosphor effect, as well as a setting to adjust the horizontal sharpness? The latter could be done quite simply with a stock shader pass that prescales horizontally by two, but it can also be baked into the shader similar to how CRT-Geom-Sharpness does it. Of course, you could also possibly go the GTU route, with fine adjustments and stuff.

Do you mean the mask code I ā€œkidnappedā€ from cgwgā€™s? Yes, good sugestion, Iā€™ll make it an option in the next version.

I donā€™t know the GTU route. Is there a good reason to sharp horizontally? I thought the horizontal bicubic I used was already very sharp. :lol:

If I could keep a single shader, it would be the best. So, the crt-geom-sharpness is the most interesting route. But, is it really necessary?

Iā€™d say it is. At least to me, it looks a bit too blurry. Not all CRTs were that blurry (think Sony PVM monitors, a popular choice among retro game enthusiasts). Iā€™m actually the one who came up with the 2x horizontal prescale method in CRT-Geom-Sharpness, and itā€™s what Iā€™ve been using for a long time. IMO the added sharpness made it look much better.

Of course, now Iā€™m moved onto a CRT monitor with hunterkā€™s interlacing.cg, so I donā€™t really use CRT-Geom anymore, but for LCDs, your shader is looking quite good, and I do like that you chose to go with bicubic rather than Lanczos, which had visible ringing. It could just afford the option to look even sharper, IMO.

Ok, Iā€™ll borrow your approach to see if it works in my shader. And make it an option too (disabled by default, though).

I thought a PVM wouldnā€™t be as sharp as you said. So I went to that page and took the corresponding snapshot under retroarch with crt-geom-flat / sharpness. And you were right. :open_mouth: The sharpness shader is more like the PVM picture, while standard CRT-geom would be more like SVHS/RGB on a TV (with better color reproduction though).

I kinda prefer that softer rendering though. It makes the jars and barrels rounder on Zelda (and everything else). Always good to have different solutions to please everyone. :slight_smile:

Done!

// Uncomment to increase the sharpness of the scanlines //#define SHARPER

// Comment next line if you donā€™t desire the phosphor effect. #define PHOSPHOR

See if itā€™s what youā€™re talking.

V8: http://pastebin.com/qAyhRuTz

Changes:

  • Phosphor is now optional;
  • Adds a sharper feature. Activated by uncommenting a param.

Hi, This is a very nice shader, thank you so much for your work. Iā€™ve noticed a problem with the phosphor effect since v7 : Only certain games are affected (gba, wonderswan, some drivers in fba), and it seems linked to their particular resolution. Could it be related to the solution you found to fix the 1 pixel shift in v6 ? My display is 16001200, and I found that using 16011200 as a custom resolution takes care of the problem seemlessly (this or removing the phosophor effect altogether in v8).

Look specifically for this line in the shader:

float2 tex = tex1+float2(0.0000001, 0.0000001)+ps*float2(-0.5, 1.0);

And replace it by this:

float2 tex = tex1+ps*float2(-0.5, 1.0);

And tell me if the problem remains.

BTW, Is your gpu ati/amd?

That solved the problem for all the fba games I tested. The problem remains (with a different pattern) for gba games, only when using an uneven integer scale (x3, x5, x7), otherwise it works fine in x4 or x6.

My gpu is a GeForce GT220 NVIDIA.

Well, it seems I just changed the place where the bomb would explode. :lol: It seems Iā€™ll have to pass all texture lookups from vertex to fragment. Itā€™ll slow down the shader a bit, though. This is something I didnā€™t want to do. There must be some way to fix it in vertex. Iā€™m not convinced yet to pass everything to fragment yet.

Does this new pattern happen with V6?

See if this fix the problem: http://pastebin.com/6Dk4VHCV

No, I did not see any change unfortunately, but I still can make it work (using a x6 scale) so donā€™t worry too much about it.

It doesnā€™t, I have no problem whatsoever with V6.

As far as Iā€™m concerned I can work my way around this glitch by using a different resolution for gba games, so please donā€™t change everything for me, Iā€™m quite happy with the first fix you gave me ! Thanks again for sharing your work.

Ok, but what bothers me is that you arenā€™t the first person to report these strange bugs. Could you tell me the game where it happen so that I can reproduce here? (the first bug).

Of course, I understand.

With v7, all gba games emulated with the VBA-M libretto have this bug when displayed at a x5 scale. Iā€™ve seen it first when playing ā€œThe Legend of Zelda : The misnish Capā€ :

Many arcade games in the fba libretto have the same problem with v7 when displayed at 1600*1200 (but the fix you gave me solved it) : outrun : (same bug when displayed at a x5 scale)

tengai :

guwange (and other cave vertical shooters) :

cadash (fist game I showed you) :

Thanks, Iā€™ll look at it and if I find a fix Iā€™ll post a new version.

By the way, those shots are beautiful!

At that same line, use this instead and tell me if it solves:

float2 tex = tex1+ps*float2(-0.499, 1.0);

The best calibration Iā€™ve got until now is this:

// Uncomment to increase the sharpness of the scanlines //#define SHARPER

// Comment next line if you donā€™t desire the phosphor effect. #define PHOSPHOR

// Control scanlines transparency by changing this param below. Use always values between 0.0 and 1.0. #define SCANLINES_STRENGTH 0.7

// Control the beam width range by changing these two params below. Use always values between 0.0 and 1.0. #define BEAM_MIN_WIDTH 0.1 #define BEAM_MAX_WIDTH 0.7

// You can saturate colors using this parameter. #define COLOR_BOOST 1.5

// This param change the threshold from where the beam gets thicker. #define BEAM_WIDTH_SENSITIVITY 0.5

// Cool tint. Controls the blue level. CRT TVs from the 90ā€™s had a blue tint. // To turn OFF this effect, use 1.0 value. #define CRT_TV_BLUE_TINT 1.1

Iā€™ll make it default in V9 along the fix for gba at 5x5.

It works ! I havenā€™t been able to find any glitch with this fix so far.

On another note, would it be possible to have intermediate amounts of horizontal blur between the SHARPER option (too sharp for my taste) and the default effect (a bit too blurry on low resolution games such as NES or old arcade games) ?

Not with current sharpness algorithm. Itā€™s a special one from GPDP that only works at a fixed rate. Other sharpness algorithms would create ring artifacts.

Could you change the ā€˜sharperā€™ hardcode from 2.0 to a #define? That is:

#define SHARPNESS 1.5  // default is 1.0 or whatever
float2 TextureSize = float2(SHARPNESS*IN.texture_size.x, IN.texture_size.y);

That way people could adjust the sharpness to their taste.