shaders = 12

YIQ = 1.0
Cutoff = 3.6
ICutoff = 0.8
QCutoff = 0.8

textures = BlueNoiseTex

// Blue noise texture from https://github.com/Calinou/free-blue-noise-textures
// (Licensed CC0)
// This is used for dithering.
// It is expected (in composite_output.slang) that this texture is 64x64. Using
// a different size will require changes to that file.
BlueNoiseTex = ../../crt/shaders/crt-beans/blue_noise.png
BlueNoiseTex_wrap_mode = repeat
BlueNoiseTex_linear = true
BlueNoiseTex_mipmap = false

//======== Transform color space if necessary.
shader0 = ../../crt/shaders/crt-beans/transform.slang
mipmap_input0 = false
scale_type0 = source
scale0 = 1.0

//======== Low-pass filter and sample to simulate an analog signal.
// Also, convert to linear RGB for the next pass.
shader1 = ../../crt/shaders/crt-beans/filter.slang
alias1 = Filtered
mipmap_input1 = false
scale_type_x1 = absolute
scale_x1 = 1024
scale_type_y1 = source
scale_y1 = 1.0

//======== Draw the scanlines, handling interlacing and overscan.
// We do the expensive width calculations in a separate pass so that we don't
// need to duplicate them for every fragment in the next pass.
shader2 = ../../crt/shaders/crt-beans/calculate_widths.slang
mipmap_input2 = false
scale_type2 = source
scale2 = 1.0

shader3 = ../../crt/shaders/crt-beans/scanlines_cubic.slang
alias3 = Scanlines
filter_linear3 = false
wrap_mode3 = clamp_to_border
mipmap_input3 = false
scale_type3 = viewport
scale3 = 1.0

//======== Downscale 3 times (to ~1/8 size per dimension) for glow blurring.
// Downscale and perform the blur on a smaller texture for performance.
// Use a 4x4 cubic downscale to minimize aliasing and shimmering in the blur.
shader4 = ../../crt/shaders/crt-beans/cubic_downsample.slang
filter_linear4 = true
wrap_mode4 = clamp_to_border
mipmap_input4 = false
scale_type4 = source
scale4 = 0.5

shader5 = ../../crt/shaders/crt-beans/cubic_downsample.slang
filter_linear5 = true
wrap_mode5 = clamp_to_border
mipmap_input5 = false
scale_type5 = source
scale5 = 0.5

shader6 = ../../crt/shaders/crt-beans/cubic_downsample.slang
filter_linear6 = true
wrap_mode6 = clamp_to_border
mipmap_input6 = false
scale_type6 = source
scale6 = 0.5

//======== Blur for the glow: first pass horizontal, second pass vertical.
shader7 = ../../crt/shaders/crt-beans/blur_horizontal.slang
filter_linear7 = true
wrap_mode7 = clamp_to_border
mipmap_input7 = false
scale_type7 = source
scale7 = 1.0

shader8 = ../../crt/shaders/crt-beans/blur_vertical.slang
filter_linear8 = true
wrap_mode8 = clamp_to_border
mipmap_input8 = false
scale_type8 = source
scale8 = 1.0

//======== Upscale the blurred texture.
// Repeated bilinear upscales blur the texture a bit more, which is noticeable
// with small blur sigmas. However, here are no blocky artifacts like we would
// get if we upscaled straight to the viewport size. The final upscale happens
// in the composite pass.
shader9 = ../../crt/shaders/crt-beans/bilinear_upsample.slang
filter_linear9 = true
wrap_mode9 = clamp_to_border
mipmap_input9 = false
scale_type9 = source
scale9 = 2.0

shader10 = ../../crt/shaders/crt-beans/bilinear_upsample.slang
filter_linear10 = true
wrap_mode10 = clamp_to_border
mipmap_input10 = false
scale_type10 = source
scale10 = 2.0

//======== Composite the blur on the image, then convert to sRGB.
shader11 = ../../crt/shaders/crt-beans/composite_output.slang
filter_linear11 = true
wrap_mode11 = clamp_to_border
mipmap_input11 = false
scale_type11 = viewport
scale11 = 1.0
