Please show off what crt shaders can do!

Here’s a couple of shots I thought were interesting that I took today. Tried a setup without any curvature and vignette. I think they came out alright. Switched up the mask at @Squalo’s suggestion. Tweaked the deconvergence some, got a little heavy handed with it imo, but I like the effect that it causes.

3 Likes

@Syh
That’s looking a lot better IMO at least as far as the mask is concerned.

That’s a weird aspect ratio though. You should set the horizontal to 1494 pixels so that it’s a 4:3 ratio. Whatever non-integer scaling artifacts this causes will be completely hidden by the shader’s blur.

Also, just a suggestion, but you might want to reduce vertical deconvergence and keep the horizontal. I think vertical deconvergence was almost always completely obscured by the scanlines. It wouldn’t spill over so much that you’d get a whole scanline that shouldn’t be there (the blue box is a good example of this; that green scanline wouldn’t be there on a CRT). Vertical deconvergence is already represented by having a variable beam width. Hopefully this makes sense, kinda hard to explain.

Here ya go! Changed the aspect a little and removed the vertical deconvergence.

3 Likes

Very nice with my backlight cranked up! Giving up on curvature though?

That’s something I want to tackle at some point- I think it should be possible, with the right settings, to completely hide curvature-related artifacts with the shader’s blur/scaling.

Does anyone know of any experiments that have been done along these lines?

I just removed it for some tests. I can get the moire to the point where I don’t notice it, but I have to sacrifice scanline strength for it.

1 Like

I was intrigued by this old quote from byuu:

First, there’s the ratio of scanlines. The best simulation is usually 2:1 regular lines to scan lines. This is a 67% ratio, which most closely matches a TV’s “kell factor” average of ~70% (measure of scanline darkness on CRTs.) This mode is tough because the SNES output width can be 512 pixels (hires mode), which stretched to 768 is an uneven multiplier and looks atrocious. So we really need a 6x scale (4:2) to be ideal here.

(https://www.reddit.com/r/emulation/comments/42iq96/snes9x_scanlines_shader_make_the_picture_too_dark/)

Uh… okay. Everything I’ve read about Kell factor suggests that it doesn’t really have anything to do with scanlines per se, but I’ll just assume that byuu is smarter than me and knows what he’s talking about :smiley:

Here’s a quick side-by-side with a consumer-grade Trinitron to an emulator with 2:1 scanlines on a plasma TV; it’s a nearly perfect match.

5 Likes

Woow good shots, is the first one a slot mask? I was reading on TVL and it appears 300 to be a common number on consumer CRTs, meaning big fat scanlines. I wonder about beam dynamics, where it comes from in the equation, beam right, but what else.

I will run the backlight test tonight as yesterday I was busy with my presets. This new probe should be blazing fast, the spyder3 was taking hours.

Here some shots I took of my presets when setting everything up.

It gets downsized here, visit pasteboard for original 1440p.

Curious about the recent topic, I took a shot of Batman, a temperature from ~8000k renders it blue (using Smooth (FBX) palette)

7 Likes

Yeah, I’m not sure how/if Kell factor is applicable here. 2/3 ratio looks good, though.

@Dogway that mario kart shot is great.

4 Likes

Some tests with a different curvature and different vignette settings. Also re-added some lower vertical deconvergence to the images. (Less the half of the previous version.) I also think I’ll be switching the mask next shots as I’m not liking how this mask looks for these settings.

Next time I test I’ll take screens of a different game, lol. Everyone must be over the Super Mario World screens.

5 Likes

I have strong memories of playing Alex Kidd on a bad TV set. Using hunterk’s instructions to modify the newpixie shader I added a tvout pass with composite. It’s wonderfully terrible now.

5 Likes

@BendBombBoom Could you share this combined preset? I also have these memories!

1 Like

Sure. You will need two things. First here is the preset:

shaders = "6"
shader0 = "shaders_slang/crt/shaders/tvout-tweaks.slang"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = ""
float_framebuffer0 = "false"
srgb_framebuffer0 = "false"
shader1 = "shaders_slang/crt/shaders/crtsim/composite.slang"
filter_linear1 = "false"
wrap_mode1 = "clamp_to_border"
mipmap_input1 = "false"
alias1 = ""
float_framebuffer1 = "false"
srgb_framebuffer1 = "false"
shader2 = "shaders_slang/crt/shaders/newpixie/accumulate2.slang"
filter_linear2 = "true"
wrap_mode2 = "clamp_to_border"
mipmap_input2 = "false"
alias2 = "accum1"
float_framebuffer2 = "false"
srgb_framebuffer2 = "false"
scale_type_x2 = "source"
scale_x2 = "1.000000"
scale_type_y2 = "source"
scale_y2 = "1.000000"
shader3 = "shaders_slang/crt/shaders/newpixie/blur_horiz.slang"
filter_linear3 = "true"
wrap_mode3 = "clamp_to_border"
mipmap_input3 = "false"
alias3 = "blur1"
float_framebuffer3 = "false"
srgb_framebuffer3 = "false"
scale_type_x3 = "source"
scale_x3 = "1.000000"
scale_type_y3 = "source"
scale_y3 = "1.000000"
shader4 = "shaders_slang/crt/shaders/newpixie/blur_vert.slang"
filter_linear4 = "true"
wrap_mode4 = "clamp_to_border"
mipmap_input4 = "false"
alias4 = "blur2"
float_framebuffer4 = "false"
srgb_framebuffer4 = "false"
scale_type_x4 = "source"
scale_x4 = "1.000000"
scale_type_y4 = "source"
scale_y4 = "1.000000"
shader5 = "shaders_slang/crt/shaders/newpixie/newpixie-crt.slang"
filter_linear5 = "true"
wrap_mode5 = "clamp_to_border"
mipmap_input5 = "false"
alias5 = ""
float_framebuffer5 = "false"
srgb_framebuffer5 = "false"
parameters = "TVOUT_RESOLUTION;TVOUT_COMPOSITE_CONNECTION;TVOUT_TV_COLOR_LEVELS;TVOUT_RESOLUTION_Y;TVOUT_RESOLUTION_I;TVOUT_RESOLUTION_Q;Tuning_Sharp;Tuning_Persistence_R;Tuning_Persistence_G;Tuning_Persistence_B;Tuning_Bleed;Tuning_Artifacts;NTSCLerp;NTSCArtifactScale;animate_artifacts;acc_modulate;blur_x;blur_y;use_frame;curvature"
TVOUT_RESOLUTION = "256.000000"
TVOUT_COMPOSITE_CONNECTION = "1.000000"
TVOUT_TV_COLOR_LEVELS = "0.000000"
TVOUT_RESOLUTION_Y = "512.000000"
TVOUT_RESOLUTION_I = "163.199997"
TVOUT_RESOLUTION_Q = "89.599998"
Tuning_Sharp = "0.200000"
Tuning_Persistence_R = "0.065000"
Tuning_Persistence_G = "0.050000"
Tuning_Persistence_B = "0.050000"
Tuning_Bleed = "0.500000"
Tuning_Artifacts = "0.300000"
NTSCLerp = "1.000000"
NTSCArtifactScale = "480.000000"
animate_artifacts = "1.000000"
acc_modulate = "0.650000"
blur_x = "1.000000"
blur_y = "1.000000"
use_frame = "0.000000"
curvature = "2.000000"
textures = "frametexture;NTSCArtifactSampler;shadowMaskSampler"
frametexture = "shaders_slang/crt/shaders/newpixie/crtframe.png"
frametexture_linear = "true"
frametexture_wrap_mode = "clamp_to_border"
frametexture_mipmap = "false"
NTSCArtifactSampler = "shaders_slang/crt/shaders/crtsim/artifacts.png"
NTSCArtifactSampler_linear = "true"
NTSCArtifactSampler_wrap_mode = "clamp_to_border"
NTSCArtifactSampler_mipmap = "false"
shadowMaskSampler = "shaders_slang/crt/shaders/crtsim/mask.png"
shadowMaskSampler_linear = "true"
shadowMaskSampler_wrap_mode = "clamp_to_border"
shadowMaskSampler_mipmap = "false"

Then you will need to save this as accumulate2.slang in your shaders\shaders_slang\crt\shaders\newpixie folder. All I have done is modify accumulate.slang so the two entries that say “PassFeedback1” now say “PassFeedback3” and renamed it. I hope you enjoy.

#version 450

// newpixie CRT
// by Mattias Gustavsson
// adapted for slang by hunterk

/*
------------------------------------------------------------------------------
This software is available under 2 licenses - you may choose the one you like.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2016 Mattias Gustavsson
Permission is hereby granted, free of charge, to any person obtaining a copy of 
this software and associated documentation files (the "Software"), to deal in 
the Software without restriction, including without limitation the rights to 
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
of the Software, and to permit persons to whom the Software is furnished to do 
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all 
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 
software, either in source code form or as a compiled binary, for any purpose, 
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this 
software dedicate any and all copyright interest in the software to the public 
domain. We make this dedication for the benefit of the public at large and to 
the detriment of our heirs and successors. We intend this dedication to be an 
overt act of relinquishment in perpetuity of all present and future rights to 
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------------------
*/

layout(push_constant) uniform Push
{
	vec4 SourceSize;
	vec4 OriginalSize;
	vec4 OutputSize;
	uint FrameCount;
	float acc_modulate;
} params;

#pragma parameter acc_modulate "Accumulate Modulation" 0.65 0.0 1.0 0.01
#define modulate params.acc_modulate

#define tex0 PassFeedback3
#define tex1 Source

layout(std140, set = 0, binding = 0) uniform UBO
{
	mat4 MVP;
} global;

#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;

void main()
{
   gl_Position = global.MVP * Position;
   vTexCoord = TexCoord;
}

#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
layout(set = 0, binding = 3) uniform sampler2D PassFeedback3;

void main()
{
   vec4 a = texture(tex0, vTexCoord.xy) * vec4(modulate);
   vec4 b = texture(tex1, vTexCoord.xy);
   FragColor = max( a, b * 0.96 );
}
4 Likes

First shot is a Samsung plasma TV with a simple black line scanline filter, 2 visible lines to 1 black line. The plasma’s phosphors make it very CRT-like, as you can see.

300-400 TVL would be a common figure for consumer-grade CRTs going back to the early 80s and up through the 90s. 250 TVL is the lowest I’ve seen advertised; that was for a 9” professional monitor.

Beam dynamics are almost entirely a function of beam focus and TVL. Both slotmask and aperture grille are capable of very pronounced scanlines. A 500 TVL slotmask CRT with good beam focus will be almost identical to a 500 TVL aperture grille CRT with good beam focus at a normal viewing distance. Brightness and contrast controls on a CRT also affect the width of the scanlines.

It would be cool if we had something empirical to base the beam dynamics on; can we predict the beam spot size variation on a CRT based on color intensity/voltage and TVL? I’d like to see someone derive a function from empirical data on CRTs that associates color intensity/voltage to beam spot size variation. Then we could apply that to shaders. Don’t look at me, though. :stuck_out_tongue:

Those shots are looking great. I think you could definitely fool some CRT fans with those.

Regarding the backlight thing, now I’m not sure if this is the most important thing. What really matters for human visual perception is the contrast ratio and dynamic range. Some theater setups have like 50 nits and it looks fine in a totally dark environment.

I think what we want to do is max out the backlight and then gradually increase the scanlines and mask until white no longer appears pure white, and then lower the mask/scanlines strength until white looks pure white. Or we can measure the black/white luminance ratio if we want to get fancy.

It’s very possible for an LCD to pass the max brightness test while still having a horrible contrast ratio.

1 Like

I know, I know, I said no more Super Mario World, but these were just some test shots that I did early. I didn’t feel like re-inputing all the values for shader to take these in another game.

I’m setting the black to an off-black. Mask has been changed, still using the same deconvergence and scanline set-up that I’ve used in the last few shots, basically everythings the same.

For these shots I ended up changing some code in the shader to get the mask and scanlines to appear in the bloom halos. Let me know what you guys think about the effect, I’d like to make this effect more blurry or something, to make it less prominent but I’m having issues with that, lol. (I think the effect of the mask and scanlines appearing in the bloom halos looks better than default, imo. I feel it makes the bloom blend better with the image.) Love to hear what others think about this effect.

EDIT: Saving shader presets still works.

3 Likes

If that just started over the last couple of days, let me know in another thread because we just pushed some changes to the custom preset saving process a couple of days ago and it might have caused some problems or something.

3 Likes

I thought of an interesting idea, imo.

Instead of applying the bloom halation after the scanlines I’m going to try and apply it before the scanlines. And then do the diffusion after the scanlines.

So it’ll look like this.

Sample blur passes like normal, apply blur passes and halation adjust (setting) to the image, then apply the scanlines on top of that, then finish off the bloom by applying the diffusion after the scanlines to blur.

Edit: So that was fun, it’s not worth taking a screenshot of right now as it needs tweaked but you kinda end up with a result like crtglow.

1 Like

Some more experimenting. I think these are the happiest I’ve been with, wish I could do a little more with the scanlines but I have to sacrifice the curvature for it.

2 Likes

With the heavy deconvergence, it looks like a projection screen TV :slight_smile:

2 Likes

Are you talking about those giant monster TV’s, the rear-projection ones?

Yep, rear projection CRT. They were known for having pretty bad picture quality :stuck_out_tongue: Their big selling point was screen size.

1 Like