Dogway's grading shader (slang)

Hey @dogway & @hunterk!

I’m trying to make sure I have the most up to date Grade,

The version I have is I think from December I think and looks like this:

#pragma parameter g_gamma_in     "Signal Gamma"                                            2.50 1.80 3.0 0.05
#pragma parameter g_gamma_out    "CRT Gamma"                                               2.50 1.80 3.0 0.05
#pragma parameter g_signal_type  "Signal Type (0:RGB 1:Composite)"                         1.0 0.0 1.0 1.0
#pragma parameter g_crtgamut     "Phosphor (1:NTSC-U 2:NTSC-J 3:PAL)"                      2.0 -4.0 3.0 1.0

and the current version in the retroarch repo looks like this:

#pragma parameter g_gamma_in     "Game Embedded Gamma"                                     2.222 1.80 3.0 0.05
    #pragma parameter g_gamma_out    "CRT Electron Gun Gamma"                                  2.50  1.80 3.0 0.05
    #pragma parameter g_signal_type  "Signal Type (0:RGB 1:Composite)"                         1.0 0.0 1.0 1.0
    #pragma parameter g_crtgamut     "Phosphor (1:NTSC-U 2:NTSC-J 3:PAL)"                      2.0 -4.0 3.0 1.0

Just saying but those are identical, just the “flavor” text is different.

Is there any actually changes in code?

If you send the December copy to me, I can go over them I guess lol.

1 Like

Looks like there are a fair amount of changes

Here’s the file: https://1drv.ms/u/s!AlJgyN_LYasyx7c-Jeum189-l9F_2g?e=mBec8M

The diff between the two of them looks like this:

I took a look at dogway’s git and what is in there was updated december 10th and also matches what is in the retroarch repo

1 Like

Ok I think that the one in the libretro repo (and Dogway’s repo) are the latest as they have the most detailed comments.

And it would of course make sense that Dogway’s repo is the latest

6 Likes

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