Request: add Blargg’s RGB preset to NTSC shader(s)

Does anyone know what kind of scaling Blargg’s RGB filter is doing? Is it Lanczos?

@guest.r

@hunterk

1 Like

pretty sure it’s not doing any (net) scaling at all, since you can put CRT shaders on top of it, etc.

2 Likes

Any idea what kind of blur/interpolation it’s doing, then? Doesn’t look like gaussian. High-contrast edges are sharp/bold, and there’s some (natural looking) ringing artifacts, which is why I thought Lanczos.

@hunterk

1 Like

What do you mean?

It’s doing something I suppose as the black pixels are getting wider then, which I’m trying to fight as I really dislike that. :persevere:

602 pixels in Nestopia.
Linear rescaling in Blargg filter.

edit: Ah, you’re talking about RGB.
I’m using fast-sharpen in my ntsc presets, that worked fine.

1 Like

Ok so what does this mean? :sweat_smile:

I’ve noticed on my CRT that blargg’s RGB in snes9x changes the horizontal scaling/aspect ratio ever so slightly, which causes horizontal scrolling artefacts when the screen pans (basically every game). It’s a complete deal breaker on my setup.

Shouldn’t that be completely solved with a slight gaussian blur?

I don’t notice such artifacts when using the RGB filter with guest dr venom…

In my setup, I don’t see any such artifacts. Do you see any in the video below? Need to download and view at original size.

https://www.dropbox.com/s/wyroowukoo47y0w/Super%20Mario%20World%20(U)%20[!]-210527-174342.mkv?dl=0

1 Like

Blargg to me looked like an horizontal convolution. I don’t know how he did it since I haven’t seen the code but look here where I showed an example. The real shader would be to modulate the signal, demodulate it with a FIR or decomb filter, there are some examples in the PAL folder.

2 Likes
#define TAPS 8
const float luma_filter[TAPS + 1] = float[TAPS + 1](
   0.0019, 
   0.0052, 
   0.0035, 
   -0.0163, 
   -0.0407,
   -0.0118, 
   0.1111, 
   0.2729, 
   0.3489);

const float chroma_filter[TAPS + 1] = float[TAPS + 1](
   0.0025, 
   0.0057, 
   0.0147, 
   0.0315, 
   0.0555,
   0.0834, 
   0.1099, 
   0.1289, 
   0.1358);

Replace everything in ntsc-decode-filter-3phase.inc (slang/ntsc/shaders folder) or you can create a new .inc file and rename all #include files

Or this to keep color intact:

#define TAPS 8
const float luma_filter[TAPS + 1] = float[TAPS + 1](
   0.0019, 
   0.0052, 
   0.0035, 
   -0.0163, 
   -0.0407,
   -0.0118, 
   0.1111, 
   0.2729, 
   0.3489);

const float chroma_filter[TAPS + 1] = float[TAPS + 1](
   0.0019, 
   0.0052, 
   0.0035, 
   -0.0163, 
   -0.0407,
   -0.0118, 
   0.1111, 
   0.2729, 
   0.3489);

Edit: Sony CXA2025AS (ntsc-rgbyuv.inc)

const mat3 yiq2rgb_mat = mat3(
   1.0, 1.630, 0.317,
   1.0, -0.378, -0.466,
   1.0, -1.089, 1.677);

vec3 yiq2rgb(vec3 yiq)
{
   return yiq * yiq2rgb_mat;
}

const mat3 yiq_mat = mat3(
      0.299, 0.587, 0.114,
      0.595716, -0.274453, -0.321263,
      0.211456, -0.522591, 0.311135
);

vec3 rgb2yiq(vec3 col)
{
   return col * yiq_mat;
}
2 Likes

I have questions, what is this doing exactly?

Like ye, I get that ntsc-rgb stuff and Sony stuff at the end are happening, but like some more context would be absolutely lovely.

@ProfessorBraun

2 Likes

It allows you to control the sharpness (among other effects with other settings) ,here are some examples with screenshots.

#define CHROMA_MOD_FREQ (PI / 2.0) in ntsc-param.inc and scale_type_x = “source” scale_x = “4.0” for ntsc-pass1-svideo-2phase.slang or ntsc-pass1-svideo-3phase.slang

-With 33 taps or (32+1)

1.https://ibb.co/D861RRf

2.https://ibb.co/pPFfj2K

-25

1.https://ibb.co/gwyrNxw

2.https://ibb.co/YWMF6WK

-9

1.https://ibb.co/M6d73kj

2.https://ibb.co/R3DYG7G

Tested with crt-royale default settings except for mask and curvature. If it’s not displayed correctly,try to download them maybe.

Edit: In-game

4 Likes

-19 taps would probably be around what I’d use, if I’m to use those screenshots as a gauge.

I personally don’t understand how to adjust the tap amount myself, any pointers or anything would lovely.

Will definitely look into adapting this tho.

1 Like

Maybe someone knows the right values for 19 taps,also you can change values in guest/advanced/ntsc folder , it will work too.

2 Likes

Looks very good. So, is this it? Is this what Blargg is doing?

3 Likes

I actually don’t know, but apparently we do have access to the source code for it, just a matter of someone that’s not a smooth brain like me to figure out how to translate that into some shaders.

4 Likes

Side tangent, it would be kinda cool to have multiple tap levels built into some ntsc shaders, to change it on the fly. (Good chance it’ll cause some slowdown compared to not having a multiple tap options.)

TBH, I’d love someone to tackle an ntsc-suite in the same manner that guest had done with advanced, dogway has with grade, and HSM has done with his reflection suite.

4 Likes

Thanks! It’s not what Blargg does but let’s say that at least from a sharpness perspective it looks close. The values I posted above are from an old post of Themaister. But it can be tweaked I suppose (sharper or softer). Or someone with the source code is gonna translate that like @Syh said.

2 Likes

I know fuck-all about matlab, but the source for the scripts used to calculate the taps are located here:

and https://github.com/libretro/common-shaders/blob/master/ntsc/shaders/filter_3phase.m

And there was an older set of taps for 3-phase that I liked for the effect it had on colors, though it was evidently less accurate for whatever reason, and you can find those taps here:

4 Likes

I’ll look it over like I have some semblance of an idea of what I’m reading XD.

Appreciate it, I really will look over it.

2 Likes

I’ve found this that might interest you,look for md_ntsc_impl.h -md_ntsc.h etc

Edit:

Just tested,looks great too :+1:

5 Likes