Linear Gamma in an NTSC shader

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Linear Gamma in an NTSC shader
by on (#156449)
Hi, I'm trying to modify a shader that tries to emulate a NTSC composite signal for Retroarch, like Blargg filters do.
I'm not really knowledgeable about signal processing or coding, so please excuse me if I'm difficult to understand.

I applied a pow(rgb , 2.2) at the beginning and pow(rgb , 1/2.2) at the end of the processing.
But in between there is rgb2yiq and yiq2rgb conversion.
All the processing is made in yiq.

And in the end it makes this kind of issue: no linear gamma / linear gamma
(that's Undead Line intro on Megadrive)

Any idea what I should do there?

I'm joining the shader files.
Re: Linear Gamma in an NTSC shader
by on (#156697)
Reading about NTSC signal, I see how that's not working...

Is there any operation to apply on YIQ to make the black thinner / white larger like from here to here?
Is that even possible?
Re: Linear Gamma in an NTSC shader
by on (#156712)
The operation is "bloom", and it's an effect from how the CRT works. Hopefully that'll help searching for implementation details...
Re: Linear Gamma in an NTSC shader
by on (#156716)
Thanks for your answer but no, that's not bloom.
Re: Linear Gamma in an NTSC shader
by on (#156719)
Yes it is.
http://www.bbc.co.uk/gel/tv/device-cons ... iagnostics
http://www.guru3d.com/files_details/swe ... nload.html

It's caused by two reasons:
Primary: The higher the intensity being emitted by the electron gun in the neck of the CRT, the emitting surface gets physically larger, so the beam gets wider.
(Distant second: The beam is made of electrons, and because they all have the same negative charge they repel each other, so the higher the electron flux the more they physically spread, causing the beam to again get wider)
Re: Linear Gamma in an NTSC shader
by on (#156720)
Very high end CRTs will maintain beam pitch across different intensities. This also can vary with age, and total gain. This is the bloom effect, but it is not to be confused with the "other bloom" where a brighter image will slightly change the image dimensions (strongly a product of age of volatile parts like capacitors).
Re: Linear Gamma in an NTSC shader
by on (#156725)
Yes, sorry, it's some kind of bloom on a real hardware.
Here I just instantly think of a bloom shader that won't do what I'm aiming at.

If you look at those mario pictures I posted earlier, it happens horizontally only and doesn't change the brightness in an halo around the object.
It's like "lighter pixels push darker ones slightly on each side".
Re: Linear Gamma in an NTSC shader
by on (#156726)
Right, it's nonlinear blur. A bright value isn't (only) made brighter by emitting more electrons → photons, but also by increasing the surface area over which those are emitted.

I don't know of a fast way to do it, and based on the other shader, clearly that other person doesn't either. You could use a library of pen sizes corresponding to the luminosities. Red, green, and blue should be independent.
Re: Linear Gamma in an NTSC shader
by on (#156791)
There is a fast way to do it, and it involves a shader with different gamma for different distances to the center of the scanline.