A new little shader i did (glsl)

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

Aha! So grade CAN be gutted after all lol. That’s lovely, this shader is turning out so fun I love it.

This is the preset I been using so far:

shaders = "1"
shader0 = "shaders_glsl/crt/shaders/testing.glsl"
filter_linear0 = "true"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = ""
float_framebuffer0 = "false"
srgb_framebuffer0 = "false"
blurx = "0.450000"
blury = "0.150000"
warpx = "0.030000"
warpy = "0.040000"
smoothness = "100.000000"
beamlow = "2.000000"
beamhigh = "2.400000"
Shadowmask = "6.000000"
MaskDark = "0.600000"
GAMMA_IN = "2.200000"
glow = "0.080000"
sat = "1.150000"
contrast = "1.050000"
WP = "-40.000000"

Were you ever able to look into that interlacing issue? I still see that moire like pattern with it toggled on

2 Likes

Maybe @guest.r can give us some hint about it since he wrote that scanline code.

2 Likes

I’ll leave this post here so he can see what I’m taking about. I hope he’ll even be interested in dealing with that old version of his shader.

1 Like

I am sure he can fix it in no time if he bothers. Regarding that mask 6 if you make the calculations it creates a virtual resolution 480 x 270 at 1080p which is pretty close to a normal TV. Not bad heh :wink:

Mask 4 should be 720 x 540

1 Like

Ok so it is fixed with a simple fp.y*fp.y on integer scaling, on non-integer it creates some not-well aligned scanlines

3 Likes

Ok so actually it works even as it is, if integer is on and Y curvature off, so the problem is how it aligns to curved screen and in non-integer

2 Likes

Damn I’m not home anymore to test all of this. So you’re saying it only looks right with integer scaling and you’ll get the non aligned scanlines with non integer scaling? I hope that’s not the case cause I never use integer scaling

2 Likes