Dogway's grading shader (slang)

Why is grade failing to load again? Something about the LUT?

[ERROR] [slang]: Texture name 'SamplerLUT1' not found in semantic map, Probably the texture name or pass alias is not defined in the preset (Non-semantic textures not supported yet)
[ERROR] [slang]: Failed to reflect SPIR-V. Resource usage is inconsistent with expectations.
[ERROR] [GLCore]: Failed to create preset: "C:\RetroArch-Win64\shaders\retroarch.slangp".
[ERROR] [GLCore]: Failed to create filter chain: "C:\RetroArch-Win64\shaders\retroarch.slangp". Falling back to stock.
1 Like

This is probably because SamplerLUT1 is missing from the textures = line or the SamplerLUT1 = line is missing in your preset

Yeah I don’t get it :stuck_out_tongue:

Do you know what I need to add, specifically, to the preset file? Grade is great, but I’ve only ever been able to get it to work with guest-dr-venom. I tried adding all the samplerlut stuff from GDV’s preset to the preset I’m trying to load, but no dice.

2 Likes

Just straight swap the passes, remove the color profiles or w/e it’s called from guest and swap grade into its place.

Some assembly may be required!

Or are you trying to run grade in a completely none guest related preset/chain?

1 Like

Yeah I’m trying to add grade to geom because reasons

3 Likes

So you just need to add this

4 Likes

Thanks! :smiley: I was just missing the textures = line.

2 Likes

Now I’m getting this, no other errors:

[ERROR] [GLCore]: Failed to load LUT "C:\RetroArch-Win64\shaders\shaders\guest\advanced\lut\trinitron-lut.png".
[ERROR] [GLCore]: Failed to create preset: "C:\RetroArch-Win64\shaders\test.slangp".
[ERROR] [GLCore]: Failed to create filter chain: "C:\RetroArch-Win64\shaders\test.slangp". Falling back to stock.

:thinking:

1 Like

I think it can’t find the texture at that path.

You probably need to adjust the path to an existing texture.

2 Likes

Got it working, thanks! Not sure what was up with the weird file path earlier. :smiley:

 textures = "SamplerLUT1;SamplerLUT2;SamplerLUT3;SamplerLUT4"
SamplerLUT1 = shaders_slang/crt/shaders/guest/advanced/lut/trinitron-lut.png
SamplerLUT1_linear = true
SamplerLUT2 = shaders_slang/crt/shaders/guest/advanced/lut/inv-trinitron-lut.png
SamplerLUT2_linear = true
SamplerLUT3 = shaders_slang/crt/shaders/guest/advanced/lut/nec-lut.png
SamplerLUT3_linear = true
SamplerLUT4 = shaders_slang/crt/shaders/guest/advanced/lut/ntsc-lut.png
SamplerLUT4_linear = true 


shaders = "4"
shader0 = "shaders_slang/ntsc/shaders/ntsc-adaptive/ntsc-pass1.slang"
filter_linear0 = "false"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = ""
float_framebuffer0 = "true"
srgb_framebuffer0 = "false"
scale_type_x0 = "source"
scale_x0 = "4.000000"
scale_type_y0 = "source"
scale_y0 = "1.000000"
shader1 = "shaders_slang/ntsc/shaders/ntsc-adaptive/ntsc-pass2.slang"
filter_linear1 = "false"
wrap_mode1 = "clamp_to_border"
mipmap_input1 = "false"
alias1 = ""
float_framebuffer1 = "false"
srgb_framebuffer1 = "false"
scale_type_x1 = "source"
scale_x1 = "0.500000"
scale_type_y1 = "source"
scale_y1 = "1.000000"
shader2 = "shaders_slang/misc/grade.slang"
wrap_mode2 = "clamp_to_border"
mipmap_input2 = "false"
alias2 = ""
float_framebuffer2 = "false"
srgb_framebuffer2 = "false"
shader3 = "shaders_slang/crt/shaders/crt-geom.slang"
wrap_mode3 = "clamp_to_border"
mipmap_input3 = "false"
alias3 = ""
float_framebuffer3 = "false"
srgb_framebuffer3 = "false"
3 Likes

@Dogway

I’ve been thinking for a while that the default for vignette toggle should be off, and the default for phosphor should be 0.00. What do you think?

Also, a version of the shader without the LUT stuff would make it so much easier to combine with other shaders; just something to consider.

2 Likes

Everytime he’d do an update I’d gut the LUT code from the pass lol

Iirc I’d gut a few things each time.

2 Likes

Just wanted to mention that in the next version of the Mega Bezel the tweaked version of grade I use will have all the LUT stuff removed (Right now it’s turned off but there is still a reference to the textures)

So there is the possibility of using this version, but this probably won’t help the average user who doesn’t know about it.

6 Likes

If I stop being a giant potato, I’ll update my modified grade and send it to you @Nesguy, iirc I removed the LUT code, the vignette, and made some minor altercations to the saturation settings…

2 Likes

Trying to understand exactly how I’m supposed to use this shader. If I have HDR turned on in Retroarch (and thus on my tv), should I use this shader set to rec.2020?

When the shader is set to sRGB the different phosphor settings are only barely different but when set to rec.2020 the difference is more extreme where ntsc and pal (1-3) settings seem desaturated compared to the default 0 setting.

I updated Grade with what I’ve learned in the last 2 years. Following a summary.

After a long quest to find a trustful NTSC-J phosphor primaries I settled on a mix of various correlated ones, and comparing them to typical phosphor chemical chromaticities. It’s not a big departure from what was before but it should be more accurate now.

The main change in this version is the White Point or temperature adjustment. The function itself is not a big change, it’s simply more accurate after a custom modelled daytime locus and using CAT16 instead. But the implementation within the shader differs.

The other big change was getting rid of FCC and YIQ, they were barely used and only up to 1979. As I’m targeting NES, MS and above I don’t want to bulk up the code too much. YPbPr was also removed until I find or confirm it was indeed used in the analogue system.

And before I miss it a third big change was the gamma handling. I implemented the 1886a transfer function which is an accurate representation of a CRT gamma. In that regard with the recommended and default black level of 0.1 cd/m^2 it matches 1886 which is a simplified CRT like transfer (gamma of 2.4), but I added knobs to adjust the black level, brightness and contrast controls in 1886a in a CRT fashion. That means that adjusting the ‘black level’ to 0.0 leads to a gamma of 2.6, and same with the ‘brightness’ (aka black ‘lift’). ‘Contrast’ is a CRT gain adjustment.

Overall everything makes more sense and performance optimizations have been done all around.

It’s tagged as RC4 so please try it and give me your feedback. I also uploaded a version without the LUTs and all parameters set to noop (OFF) by default.

11 Likes

I did some comparisons with my old own presets and I dig it. The white point function now works correctly and actually shows a pleasant neutral look on the images so not as blue as before. In order to get the old “wrong” but nice looking electric blue temperature I added the parameter called “CRT Beam”, each for R,G and B. It made sense to add this as you can now control the power emmited by the elctron gun for each one. In the same sense it can work as a way to manipulate phosphor decay. As you know red phosphors were one of the first to decay so that’s why some CRTs displayed that electric blue.

Here’s a comparison with Sonic title screen (sorry I didn’t disable the sprite limit option).

The trees’ green is not so electric, the yellow ring is more pure (less green) and you can actually now see the shades in sonic’s blue (check the spikes). Aside from the “Blue-Green Tint” option I basically reduced the overall saturation as a side effect of the analogous system. In this way the clouds now pop out more, the red ribbon isn’t so glaring and the belly and mouth are more skin like toned.

#reference "shaders_slang/misc/grade_new.slangp"
g_space_out = "-1.000000"
g_Dim_to_Dark = "0.000000"
g_U_MUL = "0.950000"
g_V_MUL = "0.950000"
g_CRT_br = "0.750000"
g_lum_fix = "1.000000"
rg = "0.020000"
bg = "0.055000"

Now with SMW. In this case the overall look is not as pale or washed out, that is more neutral like, even so I could still raise saturation and “CRT Beam Red” to make it pop out a little more. The main thing to observe here is the cloud rim, see how now the two blue shades are distinguished when they make the transition from white to the sky’s blue, so they give a better illusion of blending with the background.

noop

Old preset

New preset

#reference "shaders_slang/misc/grade_new.slangp"
g_space_out = "-1.000000"
g_Dim_to_Dark = "0.000000"
g_U_MUL = "0.900000"
g_V_MUL = "0.950000"
g_CRT_br = "0.700000"
g_sat = "-0.050000"
g_vibr = "-1.000000"

Finally I googled up on the phosphors of the Toshiba A68KJU96X used in the Nanao CRT’s but couldn’t find anything relevant. What I found is that they seemed to use an illuminant of 0.285,0.285 (about 9700K) so I’d say that for arcade systems up to Naomi or so (rear projection CRTs) you can use the NTSC-J phosphors with a temperature of 9696K.

If there’s no inconvenience I will make RC3 final and update all my uploaded presets.

9 Likes

Hi, great to see you here, and I’m really excited about the update!!!

I have a question about gamma. There previously were a gamma in and electron gamma out parameters and it seems these are not used anymore and that black level of 0 is equivalent to an input gamma of 2.4 and an electron gun gamma of 2.6 and then the Contrast equates to a gamma adjustment.

I’m thinking about how to transition Mega Bezel users… So if someone wanted to have the equivalent of 2.4 gamma in and 2.4 electron gamma, would this be a contrast of -0.2 ?

4 Likes

With the default CRT black level of 0.1 you get a gamma of 2.4, which is the standard for Rec709/Rec2020 and the 1886 transfer function for dim surrounds, except if you enable the dim to dark option which takes it to 2.45 gamma for the mentioned spaces.

So now you control the system emulated gamma with the CRT black level option. 0.1 being 2.4, 0.0 being 2.6 and varying in between. I can make a function fit to remap the values so the effective gamma can be shown in the OSD for adjustment purposes (check at the bottom).

One thing I didn’t mention is that phosphor dynamics apply their own gamma if they are non-linear. Here is a summary.

So for example 2.4 converts to 2.75 with a phosphor gamma of 1/0.88. To get an effective gamma of 2.4 you would need to set the CRT gamma to 2.1 but you can’t reach that with CRT black level limit of 0.35. Only when phosphor dynamics are 1/0.9 you can set CRT black level to 0.35 and match the gamma of 2.55=2.3^(1/0.9)

(EDIT: or leave black level at 0.1 and raise brightness to 30 as per the below expression)

Scanline shaders should notify the gamma change when phosphor dynamics are applied, so you can make more sense of the whole system gamma.

To note “CRT black level” won’t make a big change on the black lift/pedestal, it’s mainly for calculating gamma, to actually raise the pedestal you use CRT brightness, but obviously any change in range will modify the gamma which is assumed.

Here is the expression for the effective gamma:

bl=0.1   # Black Level
br=0     # CRT Brightness
bl_gamma = 1.0/(-0.054348*pow(exp(bl)    ,-9.45461)+0.437886)
br_gamma = 1.0/( 2.057430*pow(exp(br/10.),0.028201)-1.060440)
gamma    = pow(bl_gamma,br_gamma)

Then you have to account for the phosphor dynamics gamma on top.

sys_gamma = pow(gamma,ph_gamma)

2 Likes

So in layman’s terms would it be possible to setup the new shader in a way that mimics the incumbent ones or provides a toggle to enable the old behavior so as to more or less act as a passthrough to allow existing Mega Bezel Reflection Shader presets to look the same as before in order to smooth/ease the transition?

This might be necessary for the newer implementation to not break any existing custom fine tuned black level, colour temperature or gamma adjustments which might have been made prior to these developments.

Other than that if integrated in the current form, the effects on the existing ecosystems of presets might be a bit unpredictable, as in might be better in some instances (best case) but might also be worse in other instances (worst case) and require a retuning/calibration of all existing presets.

1 Like