1# IMPORTANT: 2# Shader passes need to know details about the image in the mask_texture LUT 3# files, so set the following constants in user-cgp-constants.h accordingly: 4# 1.) mask_triads_per_tile = (number of horizontal triads in mask texture LUT's) 5# 2.) mask_texture_small_size = (texture size of mask*texture_small LUT's) 6# 3.) mask_texture_large_size = (texture size of mask*texture_large LUT's) 7# 4.) mask_grille_avg_color = (avg. brightness of mask_grille_texture* LUT's, in [0, 1]) 8# 5.) mask_slot_avg_color = (avg. brightness of mask_slot_texture* LUT's, in [0, 1]) 9# 6.) mask_shadow_avg_color = (avg. brightness of mask_shadow_texture* LUT's, in [0, 1]) 10# Shader passes also need to know certain scales set in this .slangp, but their 11# compilation model doesn't currently allow the .slangp file to tell them. Make 12# sure to set the following constants in user-cgp-constants.h accordingly too: 13# 1.) bloom_approx_scale_x = scale_x2 14# 2.) mask_resize_viewport_scale = float2(scale_x6, scale_y5) 15# Finally, shader passes need to know the value of geom_max_aspect_ratio used to 16# calculate scale_y5 (among other values): 17# 1.) geom_max_aspect_ratio = (geom_max_aspect_ratio used to calculate scale_y5) 18 19shaders = "14" 20 21# NTSC Shader Passes 22shader0 = "../ntsc/shaders/ntsc-adaptive/ntsc-pass1.slang" 23shader1 = "../ntsc/shaders/ntsc-adaptive/ntsc-pass2.slang" 24 25filter_linear0 = false 26filter_linear1 = false 27 28scale_type_x0 = absolute 29scale_type_y0 = source 30scale_x0 = 1536 31scale_y0 = 1.0 32frame_count_mod0 = 2 33float_framebuffer0 = true 34 35scale_type1 = source 36scale_x1 = 0.5 37scale_y1 = 1.0 38 39# Set an identifier, filename, and sampling traits for the phosphor mask texture. 40# Load an aperture grille, slot mask, and an EDP shadow mask, and load a small 41# non-mipmapped version and a large mipmapped version. 42# TODO: Test masks in other directories. 43textures = "mask_grille_texture_small;mask_grille_texture_large;mask_slot_texture_small;mask_slot_texture_large;mask_shadow_texture_small;mask_shadow_texture_large" 44mask_grille_texture_small = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png" 45mask_grille_texture_large = "shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5Spacing.png" 46mask_slot_texture_small = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png" 47mask_slot_texture_large = "shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png" 48mask_shadow_texture_small = "shaders/crt-royale/TileableLinearShadowMaskEDPResizeTo64.png" 49mask_shadow_texture_large = "shaders/crt-royale/TileableLinearShadowMaskEDP.png" 50mask_grille_texture_small_wrap_mode = "repeat" 51mask_grille_texture_large_wrap_mode = "repeat" 52mask_slot_texture_small_wrap_mode = "repeat" 53mask_slot_texture_large_wrap_mode = "repeat" 54mask_shadow_texture_small_wrap_mode = "repeat" 55mask_shadow_texture_large_wrap_mode = "repeat" 56mask_grille_texture_small_linear = "true" 57mask_grille_texture_large_linear = "true" 58mask_slot_texture_small_linear = "true" 59mask_slot_texture_large_linear = "true" 60mask_shadow_texture_small_linear = "true" 61mask_shadow_texture_large_linear = "true" 62mask_grille_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod 63mask_grille_texture_large_mipmap = "true" # Essential for hardware-resized masks 64mask_slot_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod 65mask_slot_texture_large_mipmap = "true" # Essential for hardware-resized masks 66mask_shadow_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod 67mask_shadow_texture_large_mipmap = "true" # Essential for hardware-resized masks 68 69 70# Pass2: Linearize the input based on CRT gamma and bob interlaced fields. 71# (Bobbing ensures we can immediately blur without getting artifacts.) 72shader2 = "shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.slang" 73alias2 = "ORIG_LINEARIZED" 74filter_linear2 = "false" 75scale_type2 = "source" 76scale2 = "1.0" 77srgb_framebuffer2 = "true" 78 79# Pass3: Resample interlaced (and misconverged) scanlines vertically. 80# Separating vertical/horizontal scanline sampling is faster: It lets us 81# consider more scanlines while calculating weights for fewer pixels, and 82# it reduces our samples from vertical*horizontal to vertical+horizontal. 83# This has to come right after ORIG_LINEARIZED, because there's no 84# "original_source" scale_type we can use later. 85shader3 = "shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.slang" 86alias3 = "VERTICAL_SCANLINES" 87filter_linear3 = "true" 88scale_type_x3 = "source" 89scale_x3 = "1.0" 90scale_type_y3 = "viewport" 91scale_y3 = "1.0" 92#float_framebuffer3 = "true" 93srgb_framebuffer3 = "true" 94 95# Pass4: Do a small resize blur of ORIG_LINEARIZED at an absolute size, and 96# account for convergence offsets. We want to blur a predictable portion of the 97# screen to match the phosphor bloom, and absolute scale works best for 98# reliable results with a fixed-size bloom. Picking a scale is tricky: 99# a.) 400x300 is a good compromise for the "fake-bloom" version: It's low enough 100# to blur high-res/interlaced sources but high enough that resampling 101# doesn't smear low-res sources too much. 102# b.) 320x240 works well for the "real bloom" version: It's 1-1.5% faster, and 103# the only noticeable visual difference is a larger halation spread (which 104# may be a good thing for people who like to crank it up). 105# Note the 4:3 aspect ratio assumes the input has cropped geom_overscan (so it's 106# *intended* for an ~4:3 aspect ratio). 107shader4 = "shaders/crt-royale/src/crt-royale-bloom-approx.slang" 108alias4 = "BLOOM_APPROX" 109filter_linear4 = "true" 110scale_type4 = "absolute" 111scale_x4 = "320" 112scale_y4 = "240" 113srgb_framebuffer4 = "true" 114 115# Pass5: Vertically blur the input for halation and refractive diffusion. 116# Base this on BLOOM_APPROX: This blur should be small and fast, and blurring 117# a constant portion of the screen is probably physically correct if the 118# viewport resolution is proportional to the simulated CRT size. 119shader5 = "../blurs/blur9fast-vertical.slang" 120filter_linear5 = "true" 121scale_type5 = "source" 122scale5 = "1.0" 123srgb_framebuffer5 = "true" 124 125# Pass6: Horizontally blur the input for halation and refractive diffusion. 126# Note: Using a one-pass 9x9 blur is about 1% slower. 127shader6 = "../blurs/blur9fast-horizontal.slang" 128alias6 = "HALATION_BLUR" 129filter_linear6 = "true" 130scale_type6 = "source" 131scale6 = "1.0" 132srgb_framebuffer6 = "true" 133 134# Pass7: Lanczos-resize the phosphor mask vertically. Set the absolute 135# scale_x7 == mask_texture_small_size.x (see IMPORTANT above). Larger scales 136# will blur, and smaller scales could get nasty. The vertical size must be 137# based on the viewport size and calculated carefully to avoid artifacts later. 138# First calculate the minimum number of mask tiles we need to draw. 139# Since curvature is computed after the scanline masking pass: 140# num_resized_mask_tiles = 2.0; 141# If curvature were computed in the scanline masking pass (it's not): 142# max_mask_texel_border = ~3.0 * (1/3.0 + 4.0*sqrt(2.0) + 0.5 + 1.0); 143# max_mask_tile_border = max_mask_texel_border/ 144# (min_resized_phosphor_triad_size * mask_triads_per_tile); 145# num_resized_mask_tiles = max(2.0, 1.0 + max_mask_tile_border * 2.0); 146# At typical values (triad_size >= 2.0, mask_triads_per_tile == 8): 147# num_resized_mask_tiles = ~3.8 148# Triad sizes are given in horizontal terms, so we need geom_max_aspect_ratio 149# to relate them to vertical resolution. The widest we expect is: 150# geom_max_aspect_ratio = 4.0/3.0 # Note: Shader passes need to know this! 151# The fewer triads we tile across the screen, the larger each triad will be as a 152# fraction of the viewport size, and the larger scale_y5 must be to draw a full 153# num_resized_mask_tiles. Therefore, we must decide the smallest number of 154# triads we'll guarantee can be displayed on screen. We'll set this according 155# to 3-pixel triads at 768p resolution (the lowest anyone's likely to use): 156# min_allowed_viewport_triads = 768.0*geom_max_aspect_ratio / 3.0 = 341.333333 157# Now calculate the viewport scale that ensures we can draw resized_mask_tiles: 158# min_scale_x = resized_mask_tiles * mask_triads_per_tile / 159# min_allowed_viewport_triads 160# scale_y7 = geom_max_aspect_ratio * min_scale_x 161# # Some code might depend on equal scales: 162# scale_x8 = scale_y7 163# Given our default geom_max_aspect_ratio and min_allowed_viewport_triads: 164# scale_y7 = 4.0/3.0 * 2.0/(341.33333 / 8.0) = 0.0625 165# IMPORTANT: The scales MUST be calculated in this way. If you wish to change 166# geom_max_aspect_ratio, update that constant in user-cgp-constants.h! 167shader7 = "shaders/crt-royale/src/crt-royale-mask-resize-vertical.slang" 168filter_linear7 = "true" 169scale_type_x7 = "absolute" 170scale_x7 = "64" 171scale_type_y7 = "viewport" 172scale_y7 = "0.0625" # Safe for >= 341.333 horizontal triads at viewport size 173#srgb_framebuffer7 = "false" # mask_texture is already assumed linear 174 175# Pass8: Lanczos-resize the phosphor mask horizontally. scale_x8 = scale_y7. 176# TODO: Check again if the shaders actually require equal scales. 177shader8 = "shaders/crt-royale/src/crt-royale-mask-resize-horizontal.slang" 178alias8 = "MASK_RESIZE" 179filter_linear8 = "false" 180scale_type_x8 = "viewport" 181scale_x8 = "0.0625" 182scale_type_y8 = "source" 183scale_y8 = "1.0" 184#srgb_framebuffer8 = "false" # mask_texture is already assumed linear 185 186# Pass9: Resample (misconverged) scanlines horizontally, apply halation, and 187# apply the phosphor mask. 188shader9 = "shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang" 189alias9 = "MASKED_SCANLINES" 190filter_linear9 = "true" # This could just as easily be nearest neighbor. 191scale_type9 = "viewport" 192scale9 = "1.0" 193#float_framebuffer9 = "true" 194srgb_framebuffer9 = "true" 195 196# Pass 10: Compute a brightpass. This will require reading the final mask. 197shader10 = "shaders/crt-royale/src/crt-royale-brightpass.slang" 198alias10 = "BRIGHTPASS" 199filter_linear10 = "true" # This could just as easily be nearest neighbor. 200scale_type10 = "viewport" 201scale10 = "1.0" 202srgb_framebuffer10 = "true" 203 204# Pass 11: Blur the brightpass vertically 205shader11 = "shaders/crt-royale/src/crt-royale-bloom-vertical.slang" 206filter_linear11 = "true" # This could just as easily be nearest neighbor. 207scale_type11 = "source" 208scale11 = "1.0" 209srgb_framebuffer11 = "true" 210 211# Pass 12: Blur the brightpass horizontally and combine it with the dimpass: 212shader12 = "shaders/crt-royale/src/crt-royale-bloom-horizontal-reconstitute.slang" 213filter_linear12 = "true" 214scale_type12 = "source" 215scale12 = "1.0" 216srgb_framebuffer12 = "true" 217 218# Pass 13: Compute curvature/AA: 219shader13 = "shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.slang" 220filter_linear13 = "true" 221scale_type13 = "viewport" 222mipmap_input13 = "true" 223texture_wrap_mode13 = "clamp_to_edge" 224 225parameters = "quality" 226quality = 1.0 227 228