A new little shader i did (glsl)

vec4 screen = COMPAT_TEXTURE(Source, p);

The screen is read

vec3 mcolor = vec3 (screen.r,screen.g ,screen.b);

A copy of screen is saved to vector 3 mcolor (XYZ, RGB or whatever).

float scanLineWeight = CalcScanLine(f.y, mcolor);

The scanline is calculated with y coordinates of f.y and reading color values stored in mcolor.

Then at the end it returns a value based on the luminance of the colors of the mcolor, without caring about the mask and simply multiply the vector then.

1 Like

Ohhhh, it’s more fundamental shader stuff I don’t understand :joy:. (Seriously thanks for your time tho, going to go try and wrap my head around that.)

But it’s true that mask doesn’t affect scanlines, indeed it’s the other way around, scanlines affect the mask even if not caring what it did to image. Actually in reality on a CRT there is no scanlines it’s just a mask :grinning:

1 Like

The proper shader would be

Read how many times we scale the source image. Let’s say 4 times. Texturesize/InputSize?

Read the simulated color r.g.b .

Decide the luminance

Divide luminance / how many times we scaled. If 4 it’s 0.25 steps. If luminance 0.75 draw 3 vertical lines, leave 1 black.

Read r.g.b values and draw vertical if R is 0.33 one dot, if G is 0.66 2 dots etc.

The CRT way :grinning:

PS and then discover lcd luminance won’t cut it lol

3 Likes

A new shader i did, observing some screenshots of consumer CRTs like this. It uses a blur filter that can also take out dithering (Megadrive, ZX Spectrum etc) :wink:

PS just tested, needs #define SAMPLES 20.0 instead of 20 to compile on my Android. Will fix in a later upload

DOWNLOAD

https://mega.nz/file/OypiHToa#V2h2qVBgDn_IVmk-Lg-uodvTgwEqs6Rte5rkSE24PYw

3 Likes

An update with fixed saturation and the Android problem too. Plus!, one tweaked version of CRT-Nes-Mini with z-fast filter, CGWG and Lottes 2 mask (RGB), saturation, blah blah etc that should display DOS VGA games properly. That should work well on 4x and 6x resolutions that i checked, but not well on 5x (scanlines not align well). If someone more experienced could help would be nice.

DOWNLOAD

https://mega.nz/file/zngl0CiY#OEylcd61QMCUFXrgBFMuXYIhbpXB7GfuY48OYsFL3vU

3 Likes

Updated consumer-crt with curvature, glow, corner and replaced the crappy scanline code that wouldn’t scale properly on 5x with superior guest.r scanline code that scales well on any scale or non-integer (screens non integer). I will settle with the changes and then pass a PR to github or hunterk will go crazy with the commits :stuck_out_tongue:

DOWNLOAD https://mega.nz/file/L2gxUQjQ#zuObX6CwMRi9W9A71PSPgyRiobIplY3uzHuiwl6dXOs

5 Likes

Re-write and pushed a PR. Now it works even on non-integer, masks added, glow, curvature and is so fast that runs full speed on my old HTC One :stuck_out_tongue:

6 Likes

Still working on this, some crazy ideas coming here and there lol. Thought something to regain lost brightness of scanlines.

float brightboost (float y,vec4 c)
{
   
	//read pixel brightness
    float lum=length(c)*0.5775;
    lum=1.8*pow(lum,0.45)-0.8; lum=clamp(lum,0.0,1.0);

    //redo our scanline calculation to get amount of light lost
    float inten = 1.0*lum+(SCANLINE *sin(y*InputSize.y*PI*(2.0*TextureSize.y/InputSize.y)));

   //apply our lost brightness back
    float result = 1.0+((1.0-inten)/2.0);
    return result;
}

scanlines applied then to a temporary copy of our screen hold before we apply this.

Results

before

after

4 Likes

Is it that you’re compositing the raw image with the image + scanlines?

Oh, I now read the code and I was wondering why something like this didn’t exist before. It’s basically a kind of “Smart Scanlines with Brightness Feedback”.

Something like this in CRT-Guest-Advanced would surely make my life a lot easier!

Another thing I thought about was clipping and saturation aware Smart Brightness control.

Currently I use different settings to compensate for the loss of brightness when using full strength mask and scanlines. If I use the post CRT Brightness Setting alone for example, 2 things might happen when pushed too far, saturation decreases giving a washed out look and white clipping occurs. I manually adjust the saturation to put back what is lost and I try to be very conservative with pushing brightness via these software multiplier controls to avoid clipping.

I can’t help but thinking, if these controls were a little more “aware” of the undesirable effects and automatically compensate for them, that would have been awesome.

So a CRT Brightness control that maybe tapers off its strength logarithmically in order to avoid clipping and that has a nice range limit that’s calibrated to some standard to avoid clipping altogether would be nice - (Anti-whiteclip or Anti-burn).

That way, us shader preset developers can just crank it up nicely to where we want without having to worry about going too far.

The next aspect of this would be that the saturation is increased automatically as brightness is increased - (Anti-washout).

I even had an idea to generate more accurate “fake scanlines” by basing them on the location of where they would have been at native resolution instead of manually specifying the number.

Brilliant out of the box thinking! @DariusG

2 Likes

I enjoy your liberal use of Black Tiger! One of my favorites :smiling_face_with_three_hearts:, so many quarters went into that one :rofl:

3 Likes

Added noise (from crt-mattias) and improved glow, different approach on masks, and a PR pushed.

1 Like

Time for another crazy scientist-idea. After observing my shot of my Trinitron here and resized to 12% Lanczos i saw some colors gain one more pixel when the other 2 are almost off (e.g R on and GB void)

So another mask based on Lottes 2 :stuck_out_tongue:

Lottes 2

new Trinitron mask, probably can be improved

4 Likes

Another mask i thought. Accurate? Not like in a CRT, but smart in gaining some light and pixel dynamics per luminance.

Based on Lottes 2

else if (Shadowmask == 8.0) { float m =fract(x.x*0.3333);

if (m<0.3333) return vec3(MaskDark,MaskLight,MaskLight*col.b);  //Cyan
if (m<0.6666) return vec3(MaskLight*col.r,MaskDark,MaskLight);  //Magenta
else return vec3(MaskLight,MaskLight*col.g,MaskDark);           //Yellow
}

This way creates a pattern xGB RxB RGx, our “pixel” has 2 stripes gap, 1 x in begin. 1 in the end, and 2 actual pixels used, GBR and BRG, the second one will light depending on pixel light (the *col.rgb multiplier)

3 Likes

Took some time to see why Glow looked like crap and improved it.

glow pattern before-after. The bigger the radius the slower it gets (and better looking), so i kept it small. Now if i can find something to reduce clipping.

2 Likes

I should start replying to you here instead of the other thread when it’s time to test something out. Speaking of testing, besides that interlacing issue I spoke of the other day, do you think it’s possible to add the vignette parameters from grade to the mix? We already know that trying to apply grade by itself doesn’t work on opengl es, but maybe gutting those two parameters from it could work along with maybe the phosphor and display color space parameters. I’m trying to see how much can be added in to this “gumbo pot” shader lol

1 Like

We’ll see what can be done but don’t want to make it super heavy in the end. If it’s light and not too much trouble (example if need to gut and tweak half of Grade like white point lol) sure.

1 Like

I’m looking forward to your experiments lol. Your shader already got me back to playing a bunch of Saturn classics anything else you add at this point will only make it better. I’m so glad you added in that slot mask

1 Like

Yeah also me I can’t play those old 8bit games e.g. Atari 2600 or Zx spectrum/c64 with sharp filters or with too much noise from ntsc filters. It just doesn’t feel right.

1 Like

Check this out, this was relatively straight-forward since contrast was already there (Grade vignette works sitting on contrast). Zero cost on performance.

P.S. have to alter contrast value a tick, since i have a switch if contrast = 1.0 not to be working, and disables vignette too that sits there.

https://mega.nz/file/rvpE3aSS#WCf9RRLlA1g5Oh-Zc2QF-Qi5T01YQlMwanexm8alyag

2 Likes