Dogway's grading shader (slang)

Yes, the 1886a function assumes a black lift depending on gamma, that’s by design from the paper. In grade-mini PR (which I will pull out in a week due to lack of interest) I added a black-lift compensation fit for this effect. I can try to port that to Grade with an extra gamma compensation as now the image would be slightly darker.

3 Likes

Interesting.

Hopefully this won’t mess up your masterpiece in any way.

I just checked over this phenomenon with a few different presets I was noticing it with with the aim of sharing some screenshots to better demonstrate what I’m talking about when I found that I hardly noticed the issue of the black lift texture being visible at Black Level values below -0.01. The difference with now and then though is now it’s still daytime and when I couldn’t get rid of the raised black texture it was at night and the room was probably much darker. At that time I was also doing some hard tweaking so I was wondering if it was persistence of vision or my mind playing tricks on me.

Today had me wondering the same because it doesn’t seem to look like I can see the texture with the naked eye when Black level is at -0.01. Initially I wasn’t seeing it in my screenshot either. However when I zoomed in on those dark areas in my screenshot, I could see those lit pixels.

Here are the results, the first three are taken from my new preset pack using the new Grade, CRT-Royale and Super XBR, while the others are taken from some experimental CRT-Guest-Advanced or NTSC presets.

New Grade, CRT-Royale and Super XBR

CRT-Guest-Advanced or NTSC

1 Like

Yes you need to test these things on dark adapted vision. And if possible isolating the shader in question, that means testing Grade solely.

Hopefully this won’t mess up your masterpiece in any way.

Not that it will mess it in any way, but doing regressions is a last measure approach. I was unable to find an operand in 1886a that would keep blacks normalized and maybe it’s impossible to do so a regression fit would be fine in this case.

I see that you added some black crushing with -0.01, and that’s fine, but I will apply the fit in a non-linear way so it will work exactly for any CRT gamma input value given. I will also study the needed gamma gain to counteract the darkening from the normalization. I don’t know when I will do this but I’ll post here when that happens. I also need to review zfast_crt_geo_svideo for further performance optimizations.

1 Like

Of course, in this case I had been using the older grade via HSM Mega Bezel Reflection Shader then CRT-Guest-Advanced/NTSC, then I paired it with my new CRT-Royale Presets. I had never seen any behavior or appearance like that until I replaced the old grade with the newer grade. So that’s the only variable that changed.

I included the screenshots using CRT-Guest-Advanced/NTSC just to show you what I do using Donkey Kong Country and what I would like to be able to do that is being somewhat hindered by the current behaviour of the new Grade.

It was only a necessary evil to attempt to get rid of the raised black level texture. I would much prefer to be able to finely adjust the Green Nintendo logo in Donkey Kong Country until it just slightly and very gradually fades into black while keeping my jet blacks which I have grown accustomed to and which help to offset the limited brightness inherent in OLED TVs relative to some of their counterparts as well as inherent in high opacity Mask and Scanlines settings due to the increased contrast provided by that 0 nit black experience.

To be honest it felt like my OLED TV was turning into an LCD TV. Lol

So in other words the raised black level is lowering my contrast ratio and I’m already limited by the style of presets I create - limited bloom, glow and halation in the name of mask preservation.

My approach is a sort of phosphor and scanlines first approach. Everything else has to fit around that concept and constraint.

Two more things to consider are the possibility of this texture clashing with the new visible inactive phosphor mask and mask wires feature from CRT-Guest Advanced and similar tube glass colour feature in Mega Bezel Reflection Shader and I also noticed inconsistency in the brightness of the lines which made up the texture i.e. each horizontal line is not the same brightness as the one above or below it.

Thank you very much for looking into this.

1 Like

@Cyber I updated Grade with several updates.

So black lift compensation is implemented now in 1886a function. Following a gamma compensation, not much though, at gamma 2.31 the black lift is about 0.1, so a gamma compensation of 0.998442 to raise darks is needed. This was regressed, not perfect fit but better none the less. Here’s my workbench.

Now you can use “Black Level” parameter alongside “Surround Luminance” to raise blacks.

Talking about “Black Level” I refactored it to mean real values in 8-bit scale. So you define +10 and it means a perfect black will be raised to an 8-bit value of 10 (0-255 scale), regardless of display gamma output.

Finally a small optimization in case you want to bypass original game colors (skip the wp_adjust function with all its matrices work). Basically you set signal_type to RGB, phosphor to sRGB, color space to sRGB or 709, and temperature to ~6504K.

6 Likes

What are the primaries of 80s-90s TVs? For some reason i can’t match my CRT colors(Trinitron, eg blue looks more red-ish in CRT). While NTSC colors improve the desaturated Microsoft RGB colors, it looks different.

I think it should be something close to P22 at around 7000K?

2 Likes

Wow! Thanks very much! Has this been pushed to the RetroArch repo yet?

1 Like

Here you can see in order 80s, 90s and RPTV. You say Trinitron, is it a model for the US or Japanese market? For the Japanese market you use P22_J, since the problem is with blues you can play with temperature or CRT beam It would never be perfect but at least in the ball-park.

What do you mean with “Microsoft RGB” Colors?

Not yet, waiting for some feedback first to minimize PRs

2 Likes

It is European. I guess it should be EBU-Rec601 PAL? Difference is almost nothing compared to default RGB colors. In any case, i am doing something wrong in code i think… I meant sRGB because it was made by Microsoft :smile:

1 Like

Well that’s interesting because you have something to compare. Could you find a combination of phosphor and temperature that roughly matches the CRT? maybe this is a case for European CRT using also P22 phosphors.

And I’m curious about what kind of controls the CRT has.

What i am doing is

Get primaries in a 3x3 matrix (find zr,zg,zb by subtracting 1-x-y etc)
get xw, yw, find zw (1-xw-yw)
get a vec3 (xw/yw, 1.0, zw/yw)
put the matrix and the vec3 here to find 3 unknowns
https://www.1728.org/unknwn3.htm

then multiply my initial matrix of primaries with matrix 3x3 
[unknown_x, 0, 0, 
0, unknown_y,0,
0,   0,  unknown_z]`

get the matrix XYZ

I would say PAL or CRT-95s is close in Grade with temp 6500, from memory didn’t check side by side.

1 Like

Try to use grade-no-LUT where everything is disabled and simply enable NTSC signal, then one phosphor and some temperature.

What you posted is unknown to me, it looks like extracting white point from the primaries and applying directly in RGB. You need to multiply primaries in xyz space and temperature reference white (not to confuse with HDR reference white) in a LMS space.

When you get the chance try a side by side comparison

This is what i am doing (have to find 3 unknowns a1, a2, a3) and the result should be same with XYZ matrix calculated the “hard way”

2 Likes

Ok, I understand now. It’s simply a forward transformation in column major order matrix. You don’t need a LMS because you are using the C white point coordinates defined for the FCC NTSC primaries.

It’s fine except that the FCC NTSC was conceived in 1953 and barely used. In 1979 it was officially deprecated although it was barely used already. Try to use SMPT-C primaries with D65 white point for the standard NTSC-U colors from 1980s and up.

2 Likes

OK so checked side by side, on grade, 3-pal and -1 709 and contrast 70, saturation 0.15 is close. Temp 5800-6000… Ntsc-j is there too at 6000k. That’s an actual pal Amiga driving the CRT

2 Likes

Strange to see a CRT so warm. Is your monitor calibrated to D65? If not it might be more blue than D65 and explain the compensation to D60.

The rest looks fine as I guess you tested without scalines/mask.

1 Like

It could be, i don’t know. But in any case blue is red-ish at points and green is blue-ish at points. Very different colors than default Windows, actually colors are absolutely brilliant. RGB is pale and desaturated, colors are not correct, red is orange-ish etc.

If you load ffc1953-fake on glsl and enter parameters 0.23, 0.52, 0.10 it’s 90% there.

1 Like

Rincewind had a post on his blog where he suggested that warm temperatures are expected of typical Amiga monitors (at least the PAL versions I would assume), so maybe this also applies to some TVs.

https://blog.johnnovak.net/2022/04/15/achieving-period-correct-graphics-in-personal-computer-emulators-part-1-the-amiga/#crt-colour-profile-and-monitor-controls

Btw. does “Red Push” factor into this? On my 2000er TV set, I adjusted down the "R-Drive (or cut?) parameter a lot, because red looked totally overblown in NTSC (this strangely applies also to RGB unless input is send from a PAL60 device, I thought there’d be no color encoding)

1 Like

That’s interesting because it matches mostly DariusG observations regarding contrast and saturation. White Point wise though it recommends 6100K but instead goes and uses the Warm white point of Guest’s Reshade port.

If I look at this image it’s hard to imagine the white point being lower than 6100K. If any I’d say 7000K, although I would need to pair it with the custom Philips primaries. This looks like a very specific scenario. I studied the match done by Guest and this is the primaries and white point:

This calibrated CRT profile covers amongst others
Philips CM8533, Philips VS-0080, and Commodore 1084
 WP: 0.317073, 0.348432 (~6174.68K)
 0.635,  0.339,  
 0.300,  0.620,
 0.154,  0.060,

Blues are mostly same as sRGB, Green is a tiny bit more pure (less blue), and Reds are less pure with more green in it. But primaries wise it doesn’t deviate much from sRGB, colors are mostly affected by the white point which seems to be out of locus but approximates to a CCT of 6175K.

One thing that picked my interest is how he recalls CRTs from the 80s (Western models I guess) with warm (D65?) white points. Is this for TV CRTs or PC CRTs?

2 Likes

In context, I think he’s refering to the RGB capable consumer monitors that were typically used with the Amiga, but also other computers, because they have various inputs and (depending on the model) connectors. Composite input means you could connect consoles also. They could even switch to color-limited digital RGB, making it possible to connect actual IBM-PC compatibles provided they used CGA or EGA 200 line (15 KHz) modes.