A new little shader i did (glsl)

I like hermite the most in this set because it smooths the aliasing while preserving the pixel art look without adding too many artifacts. Also it seems pretty sharp.

1 Like

You can find hermite in hyllian-fast (slang) as “sharper” option. True the hermite preserves pixel art the most not being as sharp as nearest or blurry as bilinear.

2 Likes

I can’t tell the difference between mitchell and bilinear.

Added “Pre-scale sharpening” to crt-consumer (slang). It can be as blurry as in bilinear or sharp as a knife. Borrowed code from sharp bilinear :wink: Soon to open a PR and be available after some time.

2x pre-scale

4 Likes

Opted for hue shift per color from Grade. Really superb in color handling.

original

crt-consumer, at least my Trinitron has that colors!

3 Likes

Guybrush looks a bit weird. Is there a color difference on the Trinitron when changing between 50 and 60 Hz RGB? I have this effect on my 20" set.

Yes there is a difference in NTSC and PAL colors. This setting is approximate to how my CRT colors look like. I didn’t have it side by side at that moment.

1 Like

Added a parameter protect white on masks

Masks will be applied based on luminance of color, thus protecting full whites (bright colors in general) , if desirable. That will give option for full mask effect on dark areas. Mask will be applied to dark scanlines in white areas though (can change if wanted).

Lottes 1 in demonstration in full power (maskDark is 0.0)

Gdv-mini mask 1 full strength in comparison.

2 Likes

Added an option for PUAE to fix that dark Atari ST palettes in some direct ports like Midnight Resistance. The story behind that is that some coders used the palette entries directly, and since ST has 8 shades each one equal 30 in RGB 255 full, and Amiga has 16 that equal 16, that resulted in some direct ports having half the color values of the ST! :upside_down_face:

corrected values

original Amiga port

ST port

4 Likes

Here is how glow works now in crt-consumer after the latest PR. Any setting above 8 pixels wreck performance on my laptop when HD 630 is in command (on battery) . Haven’t checked with the on board gtx 1060 or gtx 1070 though. But looks fantastic if 10-12, almost like my CRT.

2 Likes

Added a fairly simple mod of crt-potato, called crt-potato-BVM to use a BVM-like mask LUT with some tricks to have BVM-like scanline dynamics :wink: Needs at least 5 times scale y to do that effect.

3 Likes

It’s kinda strange, I learned of this palette problem few months ago when I tried to play MR, but I had this game back in the days on my a500 and I do not recall any color/brightness problems, is my memory kinda faulty or this was less of an issue on real hardware?

1 Like

I found something interesting, if you scale the initial image at x-axis 4 times with bilinear (320x256 becomes 1280x256) and then downscale with lanczos 2 times (we get 640x256), you effectively doubling resolution x axis and the extra pixels are used for blending. We need that 640, or else we get only artifacts downscaled to 320 again. No artifacts and bullsh**.

Irfanview built-in filters used for experimenting

Showcasing as a preset, probably ready to append it with some other shader.

shaders = "2"
feedback_pass = "0"
shader0 = "shaders_slang/stock.slang"
filter_linear0 = "true"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = ""
float_framebuffer0 = "false"
srgb_framebuffer0 = "false"
scale_type_x0 = "source"
scale_x0 = "4.000000"
scale_type_y0 = "source"
scale_y0 = "1.000000"
shader1 = "shaders_slang/windowed/shaders/lanczos3-x.slang"
filter_linear1 = "false"
wrap_mode1 = "clamp_to_edge"
mipmap_input1 = "false"
alias1 = ""
float_framebuffer1 = "false"
srgb_framebuffer1 = "false"
scale_type_x1 = "source"
scale_x1 = "0.500000"
scale_type_y1 = "source"
scale_y1 = "1.000000"

3 Likes

Here is one with scanlines

shaders = "3"
feedback_pass = "0"
shader0 = "shaders_slang/stock.slang"
filter_linear0 = "true"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = ""
float_framebuffer0 = "false"
srgb_framebuffer0 = "false"
scale_type_x0 = "source"
scale_x0 = "4.000000"
scale_type_y0 = "source"
scale_y0 = "1.000000"
shader1 = "shaders_slang/windowed/shaders/lanczos3-x.slang"
filter_linear1 = "false"
wrap_mode1 = "clamp_to_edge"
mipmap_input1 = "false"
alias1 = ""
float_framebuffer1 = "false"
srgb_framebuffer1 = "false"
scale_type_x1 = "source"
scale_x1 = "0.500000"
scale_type_y1 = "source"
scale_y1 = "1.000000"
shader2 = "shaders_slang/scanlines/shaders/scanline-fract.slang"
filter_linear2 = "false"
wrap_mode2 = "clamp_to_border"
mipmap_input2 = "false"
alias2 = ""
float_framebuffer2 = "false"
srgb_framebuffer2 = "false"
DARKNESS = "0.300000"

SCALED TO 768x224

NEAREST

BILINEAR

2 Likes

I was using a polynomial “gamma in” before with 2.9-3.8 values but that resulted in gamma 2.6 in dark areas. I found 2.8-3.6 is a better choice. Below 0.5 brightness we get a typical CRT 2.45 gamma, while above that we get closer to LCD 2.2 (in simple words, not losing any brightness in bright areas).

RED: typical LCD gamma
GREEN: typical CRT gamma but emits WAY more light
blue and purple: Our correction

You simply can’t afford to lose any brightness on an LCD :wink:

3 Likes

Here is an analysis of a typical Guest.r-Dr.Venom scanline function. It will return 2 raised in a power of (-byy) where b is our scanline beam and y is our y coordinate multiplied to scanline factor, typically 1.05 for bright and 1.35 for dark colors.

Clipboard01

Look what happens if we use a sine function as seen in various shaders. a is our color value (0.0 to 1.0) f is our scanline strength factor (0.0 to 1.0) assuming we running a NES game 224p

it gets more clear here. Sine will return -1 to 1. So in the end our color will be multiplied to (1.0 - f) or (1.0 + f) to steps of 0.002 (448 / 1 = 0.002, our y coord will have a value of 0.0 to 1.0) :upside_down_face: Tricky? :joy: Sine is hardware accelerated on GPUs after 2005 and FAST

Proof of concept, if i change a NES game y size to 4 times SourceSize.y on fakelottes that uses sine we get that typical VGA scanlines

8 Likes

Had it too on my 1084S, i remember it was like playing at night setting or something.

2 Likes

I found sines to be fast, indeed, I use them extensively in koko-aio for scanlines and low level phosphor emulation. Alongside tanh() (with a periodic triangle like carrier) for steeper grids they perform pretty well.

One thing to consider, tho, is that they wont easilly ‘scale’ to full width and that they are not so easy to manage when dealing with minimum and maximum fixed widths, for which i resort to slower pows, probably a faster alternative exists, but didn’t find a convincing one till now.

After a lot of trial and error, trying to avoid branching, my final solution is this:

float morph_shape_full(float shape, float power, float steep ) {
    float lum_scaled = power;
    float l = lum_scaled; // (already clamped)
    if (lum_scaled <= 0.5 + steep) {
        float l1 = pow(l, 4) * 15;
        shape = pow(shape, 1/sqrt(l1));
    } else {
        float l2 = (l-0.5)*2.0;
        shape = shape * (1-l2) + l2;
    }
    return shape;
}

…supposed to take a sin(x)^2 as input describing a scanline mask that will be shrinked and expanded to full width depending on the power (luminance) parameter (properly prescaled to min/max scanline width range) and optionally stays into boundaries when using steep parameter.

Play with ‘l’ parameter: https://www.desmos.com/calculator/paewbnsi7n

4 Likes

Yes indeed. I uploaded a shader using sines (crt-sines) to glsl. It mimics the crt-geom look at blazing speed, around 600 fps on an HD630 (around 850 without any shader) with many more things added, a cubic filter, color controls etc. Sines need only 1 cycle on 99% of GPUs used today. Speed is equal to crt-pi.

That shader reaches 120 fps on an old HTC One m7 full screen at it’s 1080p screen (gdv-mini runs about 30), it’s GPU only has something like 50 or 80 gflops while an HD630 has 350 or so and a Vega 8 is more than 1000. It’s 10 years old so no Vulkan, only GLSL. It runs 40 fps on an old netbook with 10 gflops (lol) while the fastest good looking one, crt-hyllian-fast runs at 25. I keep these old devices around for testing speed :wink:

4 Likes

Will take a deep look to it, thanks!

Edit:

cant’ find crt-sines, where is it?

found it

2 Likes