Lightweight LUT-Based Scanline Glow Concept + Prototype GLSL

Haven’t seen this method utilized anywhere, and the closest I’ve seen to this effect is the GTU shaders, but they’re not quite potato friendly.

The core concept is using a small texture made of several 1px-wide scanline textures meant to repeat and fill the screen, but from one side to the other in the texture the different scanline textures bloom outward. Then a quick luminosity function determines how bright the screen is at a given position and that value is used as the x coordinate, or y coordinate if vertical scanlines, of a 1px slice of the texture.

This results in scanlines that appear to glow / bloom outward when they’re bright, and remain as thin as you design them to be when it isn’t bright, resulting in a smoother image that preserves bright areas and makes the effect appear less static, while only using simple multiplication, addition, and a small texture lookup.

https://mega.nz/#!A8VhDYYY!h45ui_sAbMI9EXSMwId17M4ov4BZkI3d0dOdu8nbNQY

Here’s a few prototype shaders, Basic is the absolute minimum required for the effect, NaiveScanlines is a version that doesn’t react to luminosity for comparison, Extra has features I’ve added while trying to take the effect further, TrinitronD50 is a 3DLUT for Sony Trinitron D50 colors so that some games have better colors on an LCD. Shaders are in the Higan Quark format so that it can be quickly demoed with the GLSLdev (test.exe) program from aliaspider’s shader repo.

I heavily referenced and used parts of the PhosphorLUT shader for the groundwork, I don’t know enough to start from scratch.

Feel free to modify and incorporate it in anything else, I think I’ve taken the concept as far as I can.

9 Likes

Very nice. I did make a repeating-texture shader called crt-potato which is in the repos, the aim was to make it look similar to something like kurozumi or PVM but able to run on potatoes… it doesn’t have any adjustable parameters or luminosity features though but we could really use more performant shaders like these… I was able to run mine on an rpi3 so I was quite happy about that.

Thanks!

This is a very clever idea. I love it! It really preserves the brightness remarkably well.

If you want to submit the quark version to https://github.com/hizzlekizzle/quark-shaders, I can then convert it to the RetroArch formats, unless of course you already have RetroArch versions, in which case feel free to submit them to any of the respective shader repos and I’ll merge them straightaway.

I’m not sure how to submit the files, I typically only download files and submit issues.

I think that’s your repo though, so here’s the version with all optional the doodads I’ve been toying with like faked self-illumination in the luminance to scanline width section to mimic the effect of saturated colors appearing brighter and a Sony Trinitron 3DLUT and gamma adjustment. https://mega.nz/#!1xN2RQST!QDPxkRhMrmdLBdFwdGFGtoEMDohuXq-eJwhfA2KLsnk

The top post has the barest bones version in the demo pack, titled GritsScanlines-4px-Base.shader

I’m pretty sure I got all the if/then things done correctly but if you see any problems please fix them, it’s supposed to be fast and it can’t be doing unused maths.

1 Like

Ok, I’m getting it all cleaned up and ready to go. Is there any license you would like to have it distributed under? I frequently use public domain or sometimes GPL. I never included a license on the LUT shader because it was adapted from non-licensed code in some forum post somewhere, so… dunno what you want to do about that. I guess it’s arguable whether that code is “self-evident” enough to be unlicenseable… Anyway, just let me know. Also, should it be copyright torridgristle? or would you rather have your real name?

Public domain, and torridgristle is fine.

1 Like

I saw you added it, thanks. You can credit yourself for modifications to it, it literally wouldn’t be in there without your help.

Also the Trinitron LUT might as well go into the existing LUT directory to use with the general LUT shader. It was generated from a color profile that was inside a Sony Electronics GDM-F520 driver installer, or something similar to that, so I’m inclined to believe it’s good quality. Also it just plain looks nice on most things.

I really ought to go driver hunting again, it’s much easier than piecing things together from CRT reviews and tech manuals…

1 Like

Great shader torridgristle :slight_smile: and thanks for fixing it all up for retroarch, hunterk :slight_smile:

I do have a problem though: The scanline opacity parameter affects in-game colours for me, ie. white colours turn to black at 1.0 scanline opacity and return to being white as scanline opacity decreases. Any idea what’s going on?

This is with SNES9x/mednafen PCE HW, Windows 10 x64, AMD on Vulkan, s-lang.

Can you post a screenshot of what you’re describing?

No shaders: https://i.imgur.com/S2bF0VH.png

Scanline opacity at 0.5 w/ GritsScanlines: https://i.imgur.com/zsFDRtq.png

Scanline opacity at 1.0 w/ GritsScanlines: https://i.imgur.com/tp0zNT0.png

Happens with Vulkan and OpenGL for me

Interesting! I’m not experiencing that. What GPU/driver do you have?

This is with Radeon 18.10.1 drivers; I’ve just tried with the d3d12 backend - same result :confused:

Edit: Forgot to mention - Radeon R270X

I’d like to try this out, but I’m confused. I updated my shaders, and I now have a folder with the following:

Fake-Self-Illumination.png

Scanline-LUT-4px.png

trinitron_color.png

GritsScanlines.glsl

What am I supposed to do with the .png files? Currently I’m getting a weird flickering effect.

You don’t need to do anything with the png files. Just load the shader preset.

Ok, here’s what it looks like with the preset loaded, no changes to the parameter settings. I think I’m doing something wrong :sweat_smile: It sounds similar to what gubberball describes above.

Ah, yeah, that’s some weird GPU-specific thing we ran into with the regular LUT shader…

I’m not getting it on my dev laptop, though, which makes it hard for me to work out a solution…

Oh well, no worries!

FWIW, I’m running Windows 10 and using crappy built-in Intel graphics on an Intel NUC6CAYS.

Ah, I think I found it. Give it a few minutes/hours to populate down to the online updater and give it another shot.

1 Like

just tested it, appears to be working fine now! Thanks!

1 Like
  1. I’d like to try stacking this with the aperture grille effect from the dotmask shader, but it always turns into a rainbow smear when combined with the “stock” shader (which you need for the preset).

  2. Also, am I correct in thinking that setting gamma correction to 1.20 is the same as setting input to 2.2 and output to 2.4?

  3. I’m getting some pretty bad banding with this shader; any idea how to correct this?

This is with no changes to the params: