Looking for a way to simulate composite blending for dithering

Hey,

Roaming through internet I found this video wihich showing how composed video output actually improves quality of the picture produced by Sega Genesis.

Here is picture which showcasing a good example from the video

Now I wonder if there is a way to simulate this look with the help of shaders. So far I couldn’t find any which can do close to what is showed on the picture. My favorite CRT-lottes and all shaders based on shadow mask failed to blend fixels to make a smooth gradients.

I’ve heard JINC2 resize is good for dealing with dithering. Can it be combined together with a CTR-shader to do thhe job?

Sure, JINC2 works well. There are also some shaders like mdapt/gdapt that will blend dithering patterns, but IMO the best way to do it is just to simulate composite video using one of the NTSC shaders. GTUv50 is also really great for blending dithering while keeping a clean picture.

2 Likes

Thanks Hunter.

I’ve managed to almost got what I was looking for with my shader chain I posted in other thread.

GTU+blendoverlay https://pastebin.com/xXQEhczQ

I just had to lower Signal Resolution Y to 128

Now I need some bloom to add.

2 Likes

OK, maybe 128 it’s to much. Image turns way to blury for certain games.

Signal Resolution Y = 160 is enough to get the job done.

1 Like

I’ve inconropated Torridgristle’s Glow shader and reduced brightness so white is not clipping anymore and gradients are smoother now. White text (not on the picture below) looks much better as well. I’ve also reduced slot-mask size so now it’s not like in your face.

shaders = 8

shader0 = "shaders_slang\crt\shaders\gtu-v050\pass1.slang"
scale_type0 = source
scale0 = 1.0
float_framebuffer0 = true

shader1 = "shaders_slang\crt\shaders\gtu-v050\pass2.slang"
scale_type_x1 = viewport
scale_x1 = 1.0
scale_type_y1 = source
scale_y1 = 1.0
filter_linear1 = true
float_framebuffer1 = true

shader2 = "shaders_slang\crt\shaders\gtu-v050\pass3.slang"
scale_type2 = viewport
scale_2 = 1.0
filter_linear2 = false

shader3 = "shaders_slang\reshade\shaders\blendoverlay\blendoverlay.slang"
textures = "overlay"
overlay = "textures\grayscale-slotmask.png"

shader4 = shaders_slang\crt\shaders\torridgristle\Brighten.slang
filter_linear4 = true
alias4 = candy_ref

shader5 = shaders_slang\crt\shaders\torridgristle\sunset-gaussian-vert.slang
filter_linear5 = true
scale_type5 = source

shader6 = shaders_slang\crt\shaders\torridgristle\sunset-gaussian-horiz.slang
filter_linear6 = true
scale_type6 = source

shader7 = shaders_slang\crt\shaders\torridgristle\Candy-Bloom.slang
filter_linear7 = true

parameters = "compositeConnection;signalResolution;signalResolutionI;signalResolutionQ;noScanlines;tvVerticalResolution;blackLevel;contrast;LUTWidth;LUTHeight;OverlayMix;BrightenLevel;BrightenAmount;GlowLevel;GlowTightness"
compositeConnection = "0.000000"
signalResolution = "160.000000"
signalResolutionI = "83.000000"
signalResolutionQ = "25.000000"
noScanlines = "1.000000"
tvVerticalResolution = "250.000000"
blackLevel = "0.060000"
contrast = "1.000000"
LUTHeight = "4.000000"
LUTWidth = "4.000000"
OverlayMix = "0.500000"
BrightenLevel = 2.0;
BrightenAmount = 0.1;
GlowLevel = 1.0;
GlowTightness = 0.8;
3 Likes

Here is another example of how this shader deals with dithering

No shader (biliner filer enabled in RA) || Shader applied

|

1 Like

I can’t get the darn thing to work. Tried to rename the files. Tried recreating it in menu. Just reverts to previous shader.

It may be because I’m using custom location for slot-mask texture. Try this one

“shaders_slang\reshade\shaders\blendoverlay\grayscale_slotmask.png”.

It’s a default location for all shaders though it’s a bit different compare to mine as I’m using black outlines instead of grey.

And don’t forget you have to save it in “shaders” directory of RetroArch.

1 Like

thank you. works great

I got a similar dithering effect combining composite shader + horizontal blur + film effect. This is the result:

1 Like

Here, the well known Sonic’s waterfall LOL

1 Like

Hey i did a glsl version using dotmask instead of blendoverlay.

  1. https://pasteboard.co/IpVbWa7.png
  2. https://pasteboard.co/IpVcbPR.png
  3. https://pasteboard.co/IpVct6h.png
  4. https://pasteboard.co/IpVcD0z.png
  5. https://pasteboard.co/IpVcOxv.png
shaders = "5"
shader0 = "shaders_glsl\crt\shaders\gtu-v050\pass1.glsl"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = ""
float_framebuffer0 = "true"
srgb_framebuffer0 = "false"
scale_type_x0 = "source"
scale_x0 = "1.000000"
scale_type_y0 = "source"
scale_y0 = "1.000000"
shader1 = "shaders_glsl\crt\shaders\gtu-v050\pass2.glsl"
filter_linear1 = "false"
wrap_mode1 = "clamp_to_border"
mipmap_input1 = "false"
alias1 = ""
float_framebuffer1 = "true"
srgb_framebuffer1 = "false"
scale_type_x1 = "viewport"
scale_x1 = "1.000000"
scale_type_y1 = "source"
scale_y1 = "1.000000"
shader2 = "shaders_glsl\crt\shaders\gtu-v050\pass3.glsl"
filter_linear2 = "false"
wrap_mode2 = "clamp_to_border"
mipmap_input2 = "false"
alias2 = ""
float_framebuffer2 = "false"
srgb_framebuffer2 = "false"
scale_type_x2 = "viewport"
scale_x2 = "1.000000"
scale_type_y2 = "viewport"
scale_y2 = "1.000000"
shader3 = "shaders_glsl\crt\shaders\dotmask.glsl"
wrap_mode3 = "clamp_to_border"
mipmap_input3 = "false"
alias3 = ""
float_framebuffer3 = "false"
srgb_framebuffer3 = "false"
shader4 = "shaders_glsl\misc\image-adjustment.glsl"
wrap_mode4 = "clamp_to_border"
mipmap_input4 = "false"
alias4 = ""
float_framebuffer4 = "false"
srgb_framebuffer4 = "false"
parameters = "compositeConnection;signalResolution;signalResolutionI;signalResolutionQ;noScanlines;tvVerticalResolution;blackLevel;contrast;shadowMask;DOTMASK_STRENGTH;maskDark;maskLight;ia_target_gamma;ia_monitor_gamma;ia_overscan_percent_x;ia_overscan_percent_y;ia_saturation;ia_contrast;ia_luminance;ia_black_level;ia_bright_boost;ia_R;ia_G;ia_B;ia_ZOOM;ia_XPOS;ia_YPOS;ia_TOPMASK;ia_BOTMASK;ia_LMASK;ia_RMASK;ia_GRAIN_STR;ia_SHARPEN;ia_FLIP_HORZ;ia_FLIP_VERT"
compositeConnection = "0.000000"
signalResolution = "160.000000"
signalResolutionI = "83.000000"
signalResolutionQ = "25.000000"
noScanlines = "0.000000"
tvVerticalResolution = "250.000000"
blackLevel = "0.000000"
contrast = "1.000000"
shadowMask = "1.000000"
DOTMASK_STRENGTH = "0.000000"
maskDark = "0.900000"
maskLight = "1.200000"
ia_target_gamma = "2.500000"
ia_monitor_gamma = "2.200000"
ia_overscan_percent_x = "0.000000"
ia_overscan_percent_y = "0.000000"
ia_saturation = "1.000000"
ia_contrast = "1.000000"
ia_luminance = "1.000000"
ia_black_level = "0.000000"
ia_bright_boost = "0.000000"
ia_R = "1.000000"
ia_G = "1.000000"
ia_B = "1.000000"
ia_ZOOM = "1.000000"
ia_XPOS = "0.000000"
ia_YPOS = "0.000000"
ia_TOPMASK = "0.000000"
ia_BOTMASK = "0.000000"
ia_LMASK = "0.000000"
ia_RMASK = "0.000000"
ia_GRAIN_STR = "0.000000"
ia_SHARPEN = "0.000000"
ia_FLIP_HORZ = "0.000000"
ia_FLIP_VERT = "0.000000"
1 Like

I’m trying to replace Torridgristle’s Glow from my initial shader chain as it produces strong halos with glow-tails. But it doesn’t want to work. For some reason it just ignores all the shaders prior glow-tails0 and I can’t figure out why.

shaders = 14

shader0 = "shaders_slang\crt\shaders\gtu-v050\pass1.slang"
scale_type0 = source
scale0 = 1.0
float_framebuffer0 = true

shader1 = "shaders_slang\crt\shaders\gtu-v050\pass2.slang"
scale_type_x1 = viewport
scale_x1 = 1.0
scale_type_y1 = source
scale_y1 = 1.0
filter_linear1 = true
float_framebuffer1 = true

shader2 = "shaders_slang\crt\shaders\gtu-v050\pass3.slang"
scale_type2 = viewport
scale_2 = 1.0
filter_linear2 = false

shader3 = shaders_slang\misc\ntsc-colors.slang
filter_linear3 = "true"

shader4 = "shaders_slang\reshade\shaders\blendoverlay\blendoverlay.slang"
textures = "overlay"
overlay = "textures\grayscale-slotmask.png"

shader5 = shaders_slang/crt/shaders/glow-trails/glow-trails0.slang
filter_linear5 = false
scale_type5 = source
scale5 = 1.0

shader6 = "shaders_slang/blurs/blur9fast-vertical.slang"
filter_linear6 = "true"
scale_type6 = "source"
scale6 = "1.0"
srgb_framebuffer6 = "true"

shader7 = "shaders_slang/blurs/blur9fast-horizontal.slang"
alias7 = "TRAIL_BLUR"
filter_linear7 = "true"
scale_type7 = "source"
scale7 = "1.0"
srgb_framebuffer7 = "true"

shader8 = shaders_slang/crt/shaders/glow-trails/glow-trails1.slang

shader9 = "shaders_slang/anti-aliasing/shaders/advanced-aa.slang"
alias9 = PASS1

shader10 = "shaders_slang/blurs/blur9fast-vertical.slang"
filter_linear10 = "true"
scale_type10 = "source"
scale10 = "1.0"
srgb_framebuffer10 = "true"

shader11 = "shaders_slang/blurs/blur9fast-horizontal.slang"
filter_linear11 = "true"
scale_type11 = "source"
scale11 = "1.0"
srgb_framebuffer11 = "true"

shader12 = "shaders_slang/crt/shaders/glow-trails/combine.slang"

shader13 = "shaders_slang/misc/image-adjustment.slang" 

parameters = "compositeConnection;signalResolution;signalResolutionI;signalResolutionQ;noScanlines;tvVerticalResolution;blackLevel;contrast;intensity;LUTWidth;LUTHeight;OverlayMix;mixfactor;threshold;trail_bright;glowFactor;haze_strength;luminance;bright"
compositeConnection = "0.000000"
signalResolution = "160.000000"
signalResolutionI = "83.000000"
signalResolutionQ = "25.000000"
noScanlines = "1.000000"
tvVerticalResolution = "250.000000"
blackLevel = "0.030000"
contrast = "1.000000"
intensity = "0.000000"
LUTHeight = "4.000000"
LUTWidth = "6.000000"
OverlayMix = "0.500000"
mixfactor = "0.18"
threshold = "0.90"
trail_bright = "0.30"
glowFactor = "0.10"
haze_strength = "0.25"
luminance = "1.50"
bright = "1.0"

I believe you would need to change the ‘passfeedback0’ references to ‘passfeedback8’ or whatever pass it is. It’s designed to be the first shader in the chain, and the feedback function needs to point to a specific pass.

I’ve changed two references to ‘passfeedback5’ since I have this shader 5th in my chain but it didn’t help. No changes.

Nothing seems can make glow-tails work with other shaders. I’ve tried “Original” and named alieses but still keep getting the same result. Simple glow works fine but it just can glow good enough. I can make it glowing good enough without bluring the whole picture.

@hunterk Can I ask you for a favor? I would like to have that Glow feature form CRT-royal shader as a standalone shader. So it can be combined with other shaders. It seems to me this is the only glow that can do proper halation and diffusion without destroing the image.

1 Like

I’ve manage to incorporate regular Glow (no trails) shader with GTU instead of Torridgristle’s Glow. And the result is very good.

shaders = 10

shader0 = "shaders_slang\crt\shaders\gtu-v050\pass1.slang"
scale_type0 = source
scale0 = 1.0
float_framebuffer0 = true

shader1 = "shaders_slang\crt\shaders\gtu-v050\pass2.slang"
scale_type_x1 = viewport
scale_x1 = 1.0
scale_type_y1 = source
scale_y1 = 1.0
filter_linear1 = true
float_framebuffer1 = true

shader2 = "shaders_slang\crt\shaders\gtu-v050\pass3.slang"
scale_type2 = viewport
scale_2 = 1.0
filter_linear2 = false

shader3 = shaders_slang\misc\image-adjustment.slang
filter_linear3 = "true"

shader4 = shaders_slang/crt/shaders/glow/linearize.slang
filter_linear4 = false
srgb_framebuffer4 = true

shader5 = "shaders_slang\reshade\shaders\blendoverlay\blendoverlay.slang"
textures = "overlay"
overlay = "textures\grayscale-slotmask.png"
filter_linear5 = false
scale_type5 = viewport
srgb_framebuffer5 = true
alias5 = "CRT_PASS"

shader6 = shaders_slang/crt/shaders/glow/threshold.slang
filter_linear6 = false
srgb_framebuffer6 = true

shader7 = shaders_slang/crt/shaders/glow/blur_horiz.slang
mipmap_input7 = true
filter_linear7 = true
scale_type7 = source
scale7 = 0.25
srgb_framebuffer7 = true

shader8 = shaders_slang/crt/shaders/glow/blur_vert.slang
filter_linear8 = true
srgb_framebuffer8 = true

shader9 = shaders_slang/crt/shaders/crt-hyllian-glow/resolve2.slang
filter_linear9 = true

parameters = "compositeConnection;signalResolution;signalResolutionI;signalResolutionQ;noScanlines;tvVerticalResolution;blackLevel;contrast;intensity;LUTWidth;LUTHeight;OverlayMix;GLOW_WHITEPOINT;GLOW_ROLLOFF;BLOOM_STRENGTH;SOURCE_BOOST;ia_GRAIN_STR"
compositeConnection = "0.000000"
signalResolution = "160.000000"
signalResolutionI = "83.000000"
signalResolutionQ = "25.000000"
noScanlines = "1.000000"
tvVerticalResolution = "250.000000"
blackLevel = "0.030000"
contrast = "1.000000"
intensity = "0.000000"
LUTHeight = "4.000000"
LUTWidth = "6.000000"
OverlayMix = "0.350000"
GLOW_WHITEPOINT = "1.000000"
GLOW_ROLLOFF = "1.500000"
BLOOM_STRENGTH = "0.350000"
SOURCE_BOOST = "1.150000"
ia_GRAIN_STR = "6.000000"

Here is the comparison between my previous shader and this one:

Previous || Current

||

The only thing I couldn’t do is to combine ‘ntsc-color’ (for PS1 games) and ‘image-adjust’ shaders in one shader chain. The image became broken when those two are together. (

UPD: Please mind that I’m using this custom grayscale-dotmask texture For those who want to use default texture included with shaders you might need to adjust ‘OvelayMix’

3 Likes

Is the only thing you’re using image-adjustment for is the film grain?

Yes. You can pretty much drop that shader if you are not interested in film grain. I personally find it very good as a tiny touch to overall picture presentation. It also helps to deal with banding to a certain degree and adds a bit of life for big flat texture area in NES games.

1 Like

I’ll try and hack together a copy of ntsc_color(s) with the film grain code added, sometime today…

I use the film grain code for similar reasons.

1 Like