From 682cd64071847b525e2761cb6e9a818355154e3a Mon Sep 17 00:00:00 2001 From: Monroe88 Date: Mon, 19 Mar 2018 20:00:57 -0500 Subject: [PATCH] Update SGB-style border presets --- .../gameboy-player-crt-easymode.slangp | 19 ++ .../gameboy-player-crt-geom-1x.slangp | 20 ++ .../gameboy-player-crt-royale.slangp | 215 ++++++++++++++++++ ...meboy-player-gba-color+crt-easymode.slangp | 21 ++ .../gameboy-player-tvout+interlacing.slangp | 29 +++ ...-player-tvout-gba-color+interlacing.slangp | 33 +++ .../gameboy-player-tvout-gba-color.slangp | 30 +++ .../gameboy-player-tvout.slangp | 26 +++ border/sgb/sgb+crt-easymode.slangp | 17 ++ border/sgb/sgb-crt-geom-1x.slangp | 20 ++ border/sgb/sgb-crt-royale.slangp | 215 ++++++++++++++++++ .../sgb-gbc-color-tvout+interlacing.slangp | 32 +++ border/sgb/sgb-gbc-color.slangp | 21 ++ border/sgb/sgb-tvout+interlacing.slangp | 27 +++ border/sgba/sgba-tvout+interlacing.slangp | 27 +++ .../sgba-tvout-gba-color+interlacing.slangp | 31 +++ 16 files changed, 783 insertions(+) create mode 100644 border/gameboy-player/gameboy-player-crt-easymode.slangp create mode 100644 border/gameboy-player/gameboy-player-crt-geom-1x.slangp create mode 100644 border/gameboy-player/gameboy-player-crt-royale.slangp create mode 100644 border/gameboy-player/gameboy-player-gba-color+crt-easymode.slangp create mode 100644 border/gameboy-player/gameboy-player-tvout+interlacing.slangp create mode 100644 border/gameboy-player/gameboy-player-tvout-gba-color+interlacing.slangp create mode 100644 border/gameboy-player/gameboy-player-tvout-gba-color.slangp create mode 100644 border/gameboy-player/gameboy-player-tvout.slangp create mode 100644 border/sgb/sgb+crt-easymode.slangp create mode 100644 border/sgb/sgb-crt-geom-1x.slangp create mode 100644 border/sgb/sgb-crt-royale.slangp create mode 100644 border/sgb/sgb-gbc-color-tvout+interlacing.slangp create mode 100644 border/sgb/sgb-gbc-color.slangp create mode 100644 border/sgb/sgb-tvout+interlacing.slangp create mode 100644 border/sgba/sgba-tvout+interlacing.slangp create mode 100644 border/sgba/sgba-tvout-gba-color+interlacing.slangp diff --git a/border/gameboy-player/gameboy-player-crt-easymode.slangp b/border/gameboy-player/gameboy-player-crt-easymode.slangp new file mode 100644 index 0000000..e3d452a --- /dev/null +++ b/border/gameboy-player/gameboy-player-crt-easymode.slangp @@ -0,0 +1,19 @@ +shaders = "2" +shader0 = "../shaders/imgborder-gbp.slang" +shader1 = "../../crt/shaders/crt-easymode.slang" + +scale_type_x0 = "absolute" +scale_x0 = "608" +scale_type_y0 = "absolute" +scale_y0 = "448" + +parameters = "box_scale;location;in_res_x;in_res_y" +box_scale = "2.000000" +location = "0.500000" +in_res_x = "240.000000" +in_res_y = "160.000000" +out_res_x = "608.000000" +out_res_y = "448.000000" + +textures = "BORDER" +BORDER = "gameboy-player.png" diff --git a/border/gameboy-player/gameboy-player-crt-geom-1x.slangp b/border/gameboy-player/gameboy-player-crt-geom-1x.slangp new file mode 100644 index 0000000..d71807b --- /dev/null +++ b/border/gameboy-player/gameboy-player-crt-geom-1x.slangp @@ -0,0 +1,20 @@ +shaders = 2 + +textures = "BORDER" +BORDER = "gameboy-player.png" +BORDER_linear = true + +# Pass0: Apply Game Boy Player border +shader0 = "../shaders/imgborder-gbp.slang" +scale_type_x0 = "absolute" +scale_x0 = "640" +scale_type_y0 = "absolute" +scale_y0 = "480" + +shader1 = "../../crt/shaders/crt-geom.slang" + +parameters = "box_scale;in_res_x;in_res_y;border_on_top" +box_scale = 1.0 +in_res_x = 480.0 +in_res_y = 320.0 +border_on_top = 0.0 diff --git a/border/gameboy-player/gameboy-player-crt-royale.slangp b/border/gameboy-player/gameboy-player-crt-royale.slangp new file mode 100644 index 0000000..eb44234 --- /dev/null +++ b/border/gameboy-player/gameboy-player-crt-royale.slangp @@ -0,0 +1,215 @@ +#CRT Royale with Game Boy Player border emulation + +# IMPORTANT: +# Shader passes need to know details about the image in the mask_texture LUT +# files, so set the following constants in user-cgp-constants.h accordingly: +# 1.) mask_triads_per_tile = (number of horizontal triads in mask texture LUT's) +# 2.) mask_texture_small_size = (texture size of mask*texture_small LUT's) +# 3.) mask_texture_large_size = (texture size of mask*texture_large LUT's) +# 4.) mask_grille_avg_color = (avg. brightness of mask_grille_texture* LUT's, in [0, 1]) +# 5.) mask_slot_avg_color = (avg. brightness of mask_slot_texture* LUT's, in [0, 1]) +# 6.) mask_shadow_avg_color = (avg. brightness of mask_shadow_texture* LUT's, in [0, 1]) +# Shader passes also need to know certain scales set in this .slangp, but their +# compilation model doesn't currently allow the .slangp file to tell them. Make +# sure to set the following constants in user-cgp-constants.h accordingly too: +# 1.) bloom_approx_scale_x = scale_x2 +# 2.) mask_resize_viewport_scale = float2(scale_x6, scale_y5) +# Finally, shader passes need to know the value of geom_max_aspect_ratio used to +# calculate scale_y5 (among other values): +# 1.) geom_max_aspect_ratio = (geom_max_aspect_ratio used to calculate scale_y5) + +shaders = "13" + +# Set an identifier, filename, and sampling traits for the phosphor mask texture. +# Load an aperture grille, slot mask, and an EDP shadow mask, and load a small +# non-mipmapped version and a large mipmapped version. +# TODO: Test masks in other directories. +textures = "mask_grille_texture_small;mask_grille_texture_large;mask_slot_texture_small;mask_slot_texture_large;mask_shadow_texture_small;mask_shadow_texture_large;BORDER" +mask_grille_texture_small = "../../crt/shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png" +mask_grille_texture_large = "../../crt/shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5Spacing.png" +mask_slot_texture_small = "../../crt/shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png" +mask_slot_texture_large = "../../crt/shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png" +mask_shadow_texture_small = "../../crt/shaders/crt-royale/TileableLinearShadowMaskEDPResizeTo64.png" +mask_shadow_texture_large = "../../crt/shaders/crt-royale/TileableLinearShadowMaskEDP.png" +mask_grille_texture_small_wrap_mode = "repeat" +mask_grille_texture_large_wrap_mode = "repeat" +mask_slot_texture_small_wrap_mode = "repeat" +mask_slot_texture_large_wrap_mode = "repeat" +mask_shadow_texture_small_wrap_mode = "repeat" +mask_shadow_texture_large_wrap_mode = "repeat" +mask_grille_texture_small_linear = "true" +mask_grille_texture_large_linear = "true" +mask_slot_texture_small_linear = "true" +mask_slot_texture_large_linear = "true" +mask_shadow_texture_small_linear = "true" +mask_shadow_texture_large_linear = "true" +mask_grille_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_grille_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_slot_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_slot_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_shadow_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_shadow_texture_large_mipmap = "true" # Essential for hardware-resized masks +BORDER = "gameboy-player.png" + +# Pass0: Apply Game Boy Player border +shader0 = "../shaders/imgborder-gbp.slang" +scale_type_x0 = "absolute" +scale_x0 = "608" +scale_type_y0 = "absolute" +scale_y0 = "448" + +# Pass1: Linearize the input based on CRT gamma and bob interlaced fields. +# (Bobbing ensures we can immediately blur without getting artifacts.) +shader1 = "../../crt/shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.slang" +alias1 = "ORIG_LINEARIZED" +filter_linear1 = "false" +scale_type1 = "source" +scale1 = "1.0" +srgb_framebuffer1 = "true" + +# Pass2: Resample interlaced (and misconverged) scanlines vertically. +# Separating vertical/horizontal scanline sampling is faster: It lets us +# consider more scanlines while calculating weights for fewer pixels, and +# it reduces our samples from vertical*horizontal to vertical+horizontal. +# This has to come right after ORIG_LINEARIZED, because there's no +# "original_source" scale_type we can use later. +shader2 = "../../crt/shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.slang" +alias2 = "VERTICAL_SCANLINES" +filter_linear2 = "true" +scale_type_x2 = "source" +scale_x2 = "1.0" +scale_type_y2 = "viewport" +scale_y2 = "1.0" +#float_framebuffer2 = "true" +srgb_framebuffer2 = "true" + +# Pass3: Do a small resize blur of ORIG_LINEARIZED at an absolute size, and +# account for convergence offsets. We want to blur a predictable portion of the +# screen to match the phosphor bloom, and absolute scale works best for +# reliable results with a fixed-size bloom. Picking a scale is tricky: +# a.) 400x300 is a good compromise for the "fake-bloom" version: It's low enough +# to blur high-res/interlaced sources but high enough that resampling +# doesn't smear low-res sources too much. +# b.) 320x240 works well for the "real bloom" version: It's 1-1.5% faster, and +# the only noticeable visual difference is a larger halation spread (which +# may be a good thing for people who like to crank it up). +# Note the 4:3 aspect ratio assumes the input has cropped geom_overscan (so it's +# *intended* for an ~4:3 aspect ratio). +shader3 = "../../crt/shaders/crt-royale/src/crt-royale-bloom-approx.slang" +alias3 = "BLOOM_APPROX" +filter_linear3 = "true" +scale_type3 = "absolute" +scale_x3 = "320" +scale_y3 = "240" +srgb_framebuffer3 = "true" + +# Pass4: Vertically blur the input for halation and refractive diffusion. +# Base this on BLOOM_APPROX: This blur should be small and fast, and blurring +# a constant portion of the screen is probably physically correct if the +# viewport resolution is proportional to the simulated CRT size. +shader4 = "../../blurs/blur9fast-vertical.slang" +filter_linear4 = "true" +scale_type4 = "source" +scale4 = "1.0" +srgb_framebuffer4 = "true" + +# Pass5: Horizontally blur the input for halation and refractive diffusion. +# Note: Using a one-pass 9x9 blur is about 1% slower. +shader5 = "../../blurs/blur9fast-horizontal.slang" +alias5 = "HALATION_BLUR" +filter_linear5 = "true" +scale_type5 = "source" +scale5 = "1.0" +srgb_framebuffer5 = "true" + +# Pass6: Lanczos-resize the phosphor mask vertically. Set the absolute +# scale_x5 == mask_texture_small_size.x (see IMPORTANT above). Larger scales +# will blur, and smaller scales could get nasty. The vertical size must be +# based on the viewport size and calculated carefully to avoid artifacts later. +# First calculate the minimum number of mask tiles we need to draw. +# Since curvature is computed after the scanline masking pass: +# num_resized_mask_tiles = 2.0; +# If curvature were computed in the scanline masking pass (it's not): +# max_mask_texel_border = ~3.0 * (1/3.0 + 4.0*sqrt(2.0) + 0.5 + 1.0); +# max_mask_tile_border = max_mask_texel_border/ +# (min_resized_phosphor_triad_size * mask_triads_per_tile); +# num_resized_mask_tiles = max(2.0, 1.0 + max_mask_tile_border * 2.0); +# At typical values (triad_size >= 2.0, mask_triads_per_tile == 8): +# num_resized_mask_tiles = ~3.8 +# Triad sizes are given in horizontal terms, so we need geom_max_aspect_ratio +# to relate them to vertical resolution. The widest we expect is: +# geom_max_aspect_ratio = 4.0/3.0 # Note: Shader passes need to know this! +# The fewer triads we tile across the screen, the larger each triad will be as a +# fraction of the viewport size, and the larger scale_y5 must be to draw a full +# num_resized_mask_tiles. Therefore, we must decide the smallest number of +# triads we'll guarantee can be displayed on screen. We'll set this according +# to 3-pixel triads at 768p resolution (the lowest anyone's likely to use): +# min_allowed_viewport_triads = 768.0*geom_max_aspect_ratio / 3.0 = 341.333333 +# Now calculate the viewport scale that ensures we can draw resized_mask_tiles: +# min_scale_x = resized_mask_tiles * mask_triads_per_tile / +# min_allowed_viewport_triads +# scale_y5 = geom_max_aspect_ratio * min_scale_x +# # Some code might depend on equal scales: +# scale_x6 = scale_y5 +# Given our default geom_max_aspect_ratio and min_allowed_viewport_triads: +# scale_y5 = 4.0/3.0 * 2.0/(341.33333 / 8.0) = 0.0625 +# IMPORTANT: The scales MUST be calculated in this way. If you wish to change +# geom_max_aspect_ratio, update that constant in user-cgp-constants.h! +shader6 = "../../crt/shaders/crt-royale/src/crt-royale-mask-resize-vertical.slang" +filter_linear6 = "true" +scale_type_x6 = "absolute" +scale_x6 = "64" +scale_type_y6 = "viewport" +scale_y6 = "0.0625" # Safe for >= 341.333 horizontal triads at viewport size +#srgb_framebuffer6 = "false" # mask_texture is already assumed linear + +# Pass7: Lanczos-resize the phosphor mask horizontally. scale_x6 = scale_y5. +# TODO: Check again if the shaders actually require equal scales. +shader7 = "../../crt/shaders/crt-royale/src/crt-royale-mask-resize-horizontal.slang" +alias7 = "MASK_RESIZE" +filter_linear7 = "false" +scale_type_x7 = "viewport" +scale_x7 = "0.0625" +scale_type_y7 = "source" +scale_y7 = "1.0" +#srgb_framebuffer7 = "false" # mask_texture is already assumed linear + +# Pass8: Resample (misconverged) scanlines horizontally, apply halation, and +# apply the phosphor mask. +shader8 = "../../crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang" +alias8 = "MASKED_SCANLINES" +filter_linear8 = "true" # This could just as easily be nearest neighbor. +scale_type8 = "viewport" +scale8 = "1.0" +#float_framebuffer8 = "true" +srgb_framebuffer8 = "true" + +# Pass 9: Compute a brightpass. This will require reading the final mask. +shader9 = "../../crt/shaders/crt-royale/src/crt-royale-brightpass.slang" +alias9 = "BRIGHTPASS" +filter_linear9 = "true" # This could just as easily be nearest neighbor. +scale_type9 = "viewport" +scale9 = "1.0" +srgb_framebuffer9 = "true" + +# Pass 10: Blur the brightpass vertically +shader10 = "../../crt/shaders/crt-royale/src/crt-royale-bloom-vertical.slang" +filter_linear10 = "true" # This could just as easily be nearest neighbor. +scale_type10 = "source" +scale10 = "1.0" +srgb_framebuffer10 = "true" + +# Pass 11: Blur the brightpass horizontally and combine it with the dimpass: +shader11 = "../../crt/shaders/crt-royale/src/crt-royale-bloom-horizontal-reconstitute.slang" +filter_linear11 = "true" +scale_type11 = "source" +scale11 = "1.0" +srgb_framebuffer11 = "true" + +# Pass 12: Compute curvature/AA: +shader12 = "../../crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.slang" +filter_linear12 = "true" +scale_type12 = "viewport" +mipmap_input12 = "true" +texture_wrap_mode12 = "clamp_to_edge" + diff --git a/border/gameboy-player/gameboy-player-gba-color+crt-easymode.slangp b/border/gameboy-player/gameboy-player-gba-color+crt-easymode.slangp new file mode 100644 index 0000000..ebaa4a0 --- /dev/null +++ b/border/gameboy-player/gameboy-player-gba-color+crt-easymode.slangp @@ -0,0 +1,21 @@ +shaders = "3" +shader0 = "../../handheld/shaders/color/gba-color.slang" +shader1 = "../shaders/imgborder-gbp.slang" +shader2 = "../../crt/shaders/crt-easymode.slang" + +scale_type0 = "source" +scale0 = "1.000" + +scale_type_x1 = "absolute" +scale_x1 = "608" +scale_type_y1 = "absolute" +scale_y1 = "448" + +parameters = "box_scale;location;in_res_x;in_res_y" +box_scale = "2.000000" +location = "0.500000" +in_res_x = "240.000000" +in_res_y = "160.000000" + +textures = "BORDER" +BORDER = "gameboy-player.png" diff --git a/border/gameboy-player/gameboy-player-tvout+interlacing.slangp b/border/gameboy-player/gameboy-player-tvout+interlacing.slangp new file mode 100644 index 0000000..ab54072 --- /dev/null +++ b/border/gameboy-player/gameboy-player-tvout+interlacing.slangp @@ -0,0 +1,29 @@ +shaders = "4" +shader0 = "../shaders/imgborder-gbp.slang" +shader1 = "../../crt/shaders/tvout-tweaks.slang" +shader2 = "../../misc/image-adjustment.slang" +shader3 = "../../misc/interlacing.slang" + +scale_type_x0 = "absolute" +scale_x0 = "608" +scale_type_y0 = "absolute" +scale_y0 = "448" + +scale_type_x1 = "viewport" +scale_x1 = "1.000000" +scale_type_y1 = "source" +scale_y1 = "1.000000" + +parameters = "box_scale;location;in_res_x;in_res_y;TVOUT_RESOLUTION;TVOUT_COMPOSITE_CONNECTION;TVOUT_TV_COLOR_LEVELS;enable_480i;top_field_first" +box_scale = "2.000000" +location = "0.500000" +in_res_x = "240.000000" +in_res_y = "160.000000" +TVOUT_RESOLUTION = "512.000000" +TVOUT_COMPOSITE_CONNECTION = "0.000000" +TVOUT_TV_COLOR_LEVELS = "1.000000" +enable_480i = "0.000000" +top_field_first = "1.000000" + +textures = "BORDER" +BORDER = "gameboy-player.png" diff --git a/border/gameboy-player/gameboy-player-tvout-gba-color+interlacing.slangp b/border/gameboy-player/gameboy-player-tvout-gba-color+interlacing.slangp new file mode 100644 index 0000000..78ac3a9 --- /dev/null +++ b/border/gameboy-player/gameboy-player-tvout-gba-color+interlacing.slangp @@ -0,0 +1,33 @@ +shaders = "5" +shader0 = "../../handheld/shaders/color/gba-color.slang" +shader1 = "../shaders/imgborder-gbp.slang" +shader2 = "../../crt/shaders/tvout-tweaks.slang" +shader3 = "../../misc/image-adjustment.slang" +shader4 = "../../misc/interlacing.slang" + +scale_type0 = "source" +scale0 = "1.0" + +scale_type_x1 = "absolute" +scale_x1 = "608" +scale_type_y1 = "absolute" +scale_y1 = "448" + +scale_type_x2 = "viewport" +scale_x2 = "1.000000" +scale_type_y2 = "source" +scale_y2 = "1.000000" + +parameters = "box_scale;location;in_res_x;in_res_y;TVOUT_RESOLUTION;TVOUT_COMPOSITE_CONNECTION;TVOUT_TV_COLOR_LEVELS;enable_480i;top_field_first" +box_scale = "2.000000" +location = "0.500000" +in_res_x = "240.000000" +in_res_y = "160.000000" +TVOUT_RESOLUTION = "512.000000" +TVOUT_COMPOSITE_CONNECTION = "0.000000" +TVOUT_TV_COLOR_LEVELS = "0.000000" +enable_480i = "0.000000" +top_field_first = "1.000000" + +textures = "BORDER" +BORDER = "gameboy-player.png" diff --git a/border/gameboy-player/gameboy-player-tvout-gba-color.slangp b/border/gameboy-player/gameboy-player-tvout-gba-color.slangp new file mode 100644 index 0000000..e153103 --- /dev/null +++ b/border/gameboy-player/gameboy-player-tvout-gba-color.slangp @@ -0,0 +1,30 @@ +shaders = "4" +shader0 = "../../handheld/shaders/color/gba-color.slang" +shader1 = "../shaders/imgborder-gbp.slang" +shader2 = "../../crt/shaders/tvout-tweaks.slang" +shader3 = "../../misc/image-adjustment.slang" + +scale_type0 = "source" +scale0 = "1.0" + +scale_type_x1 = "absolute" +scale_x1 = "608" +scale_type_y1 = "absolute" +scale_y1 = "448" + +scale_type_x2 = "viewport" +scale_x2 = "1.000000" +scale_type_y2 = "source" +scale_y2 = "1.000000" + +parameters = "box_scale;location;in_res_x;in_res_y;TVOUT_RESOLUTION;TVOUT_COMPOSITE_CONNECTION;TVOUT_TV_COLOR_LEVELS" +box_scale = "2.000000" +location = "0.500000" +in_res_x = "240.000000" +in_res_y = "160.000000" +TVOUT_RESOLUTION = "512.000000" +TVOUT_COMPOSITE_CONNECTION = "0.000000" +TVOUT_TV_COLOR_LEVELS = "0.000000" + +textures = "BORDER" +BORDER = "gameboy-player.png" diff --git a/border/gameboy-player/gameboy-player-tvout.slangp b/border/gameboy-player/gameboy-player-tvout.slangp new file mode 100644 index 0000000..e30e44f --- /dev/null +++ b/border/gameboy-player/gameboy-player-tvout.slangp @@ -0,0 +1,26 @@ +shaders = "3" +shader0 = "../shaders/imgborder-gbp.slang" +shader1 = "../../crt/shaders/tvout-tweaks.slang" +shader2 = "../../misc/image-adjustment.slang" + +scale_type_x0 = "absolute" +scale_x0 = "608" +scale_type_y0 = "absolute" +scale_y0 = "448" + +scale_type_x1 = "viewport" +scale_x1 = "1.000000" +scale_type_y1 = "source" +scale_y1 = "1.000000" + +parameters = "box_scale;location;in_res_x;in_res_y;TVOUT_RESOLUTION;TVOUT_COMPOSITE_CONNECTION;TVOUT_TV_COLOR_LEVELS" +box_scale = "2.000000" +location = "0.500000" +in_res_x = "240.000000" +in_res_y = "160.000000" +TVOUT_RESOLUTION = "480.000000" +TVOUT_COMPOSITE_CONNECTION = "0.000000" +TVOUT_TV_COLOR_LEVELS = "0.000000" + +textures = "BORDER" +BORDER = "gameboy-player.png" diff --git a/border/sgb/sgb+crt-easymode.slangp b/border/sgb/sgb+crt-easymode.slangp new file mode 100644 index 0000000..86c9134 --- /dev/null +++ b/border/sgb/sgb+crt-easymode.slangp @@ -0,0 +1,17 @@ +shaders = "2" +shader0 = "../shaders/imgborder-sgb.slang" +shader1 = "../../crt/shaders/crt-easymode.slang" + +scale_type_x0 = "absolute" +scale_x0 = "256" +scale_type_y0 = "absolute" +scale_y0 = "224" + +parameters = "box_scale;location;in_res_x;in_res_y" +box_scale = "1.000000" +location = "0.500000" +in_res_x = "160.000000" +in_res_y = "144.000000" + +textures = "BORDER" +BORDER = "sgb.png" diff --git a/border/sgb/sgb-crt-geom-1x.slangp b/border/sgb/sgb-crt-geom-1x.slangp new file mode 100644 index 0000000..9b95ab3 --- /dev/null +++ b/border/sgb/sgb-crt-geom-1x.slangp @@ -0,0 +1,20 @@ +shaders = 2 + +textures = "BORDER" +BORDER = "sgb.png" +BORDER_linear = true + +# Pass0: Apply Game Boy Player border +shader0 = "../shaders/imgborder-sgb.slang" +scale_type_x0 = "absolute" +scale_x0 = "256" +scale_type_y0 = "absolute" +scale_y0 = "224" + +shader1 = "../../crt/shaders/crt-geom.slang" + +parameters = "box_scale;in_res_x;in_res_y;border_on_top" +box_scale = 1.0 +in_res_x = 160.0 +in_res_y = 144.0 +border_on_top = 0.0 diff --git a/border/sgb/sgb-crt-royale.slangp b/border/sgb/sgb-crt-royale.slangp new file mode 100644 index 0000000..e21e9f7 --- /dev/null +++ b/border/sgb/sgb-crt-royale.slangp @@ -0,0 +1,215 @@ +#CRT Royale with SGB border emulation + +# IMPORTANT: +# Shader passes need to know details about the image in the mask_texture LUT +# files, so set the following constants in user-cgp-constants.h accordingly: +# 1.) mask_triads_per_tile = (number of horizontal triads in mask texture LUT's) +# 2.) mask_texture_small_size = (texture size of mask*texture_small LUT's) +# 3.) mask_texture_large_size = (texture size of mask*texture_large LUT's) +# 4.) mask_grille_avg_color = (avg. brightness of mask_grille_texture* LUT's, in [0, 1]) +# 5.) mask_slot_avg_color = (avg. brightness of mask_slot_texture* LUT's, in [0, 1]) +# 6.) mask_shadow_avg_color = (avg. brightness of mask_shadow_texture* LUT's, in [0, 1]) +# Shader passes also need to know certain scales set in this .slangp, but their +# compilation model doesn't currently allow the .slangp file to tell them. Make +# sure to set the following constants in user-cgp-constants.h accordingly too: +# 1.) bloom_approx_scale_x = scale_x2 +# 2.) mask_resize_viewport_scale = float2(scale_x6, scale_y5) +# Finally, shader passes need to know the value of geom_max_aspect_ratio used to +# calculate scale_y5 (among other values): +# 1.) geom_max_aspect_ratio = (geom_max_aspect_ratio used to calculate scale_y5) + +shaders = "13" + +# Set an identifier, filename, and sampling traits for the phosphor mask texture. +# Load an aperture grille, slot mask, and an EDP shadow mask, and load a small +# non-mipmapped version and a large mipmapped version. +# TODO: Test masks in other directories. +textures = "mask_grille_texture_small;mask_grille_texture_large;mask_slot_texture_small;mask_slot_texture_large;mask_shadow_texture_small;mask_shadow_texture_large;BORDER" +mask_grille_texture_small = "../../crt/shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5SpacingResizeTo64.png" +mask_grille_texture_large = "../../crt/shaders/crt-royale/TileableLinearApertureGrille15Wide8And5d5Spacing.png" +mask_slot_texture_small = "../../crt/shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacingResizeTo64.png" +mask_slot_texture_large = "../../crt/shaders/crt-royale/TileableLinearSlotMaskTall15Wide9And4d5Horizontal9d14VerticalSpacing.png" +mask_shadow_texture_small = "../../crt/shaders/crt-royale/TileableLinearShadowMaskEDPResizeTo64.png" +mask_shadow_texture_large = "../../crt/shaders/crt-royale/TileableLinearShadowMaskEDP.png" +mask_grille_texture_small_wrap_mode = "repeat" +mask_grille_texture_large_wrap_mode = "repeat" +mask_slot_texture_small_wrap_mode = "repeat" +mask_slot_texture_large_wrap_mode = "repeat" +mask_shadow_texture_small_wrap_mode = "repeat" +mask_shadow_texture_large_wrap_mode = "repeat" +mask_grille_texture_small_linear = "true" +mask_grille_texture_large_linear = "true" +mask_slot_texture_small_linear = "true" +mask_slot_texture_large_linear = "true" +mask_shadow_texture_small_linear = "true" +mask_shadow_texture_large_linear = "true" +mask_grille_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_grille_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_slot_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_slot_texture_large_mipmap = "true" # Essential for hardware-resized masks +mask_shadow_texture_small_mipmap = "false" # Mipmapping causes artifacts with manually resized masks without tex2Dlod +mask_shadow_texture_large_mipmap = "true" # Essential for hardware-resized masks +BORDER = "sgb.png" + +# Pass0: Apply SGB border +shader0 = "../shaders/imgborder-sgb.slang" +scale_type_x0 = "absolute" +scale_x0 = "256" +scale_type_y0 = "absolute" +scale_y0 = "224" + +# Pass1: Linearize the input based on CRT gamma and bob interlaced fields. +# (Bobbing ensures we can immediately blur without getting artifacts.) +shader1 = "../../crt/shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.slang" +alias1 = "ORIG_LINEARIZED" +filter_linear1 = "false" +scale_type1 = "source" +scale1 = "1.0" +srgb_framebuffer1 = "true" + +# Pass2: Resample interlaced (and misconverged) scanlines vertically. +# Separating vertical/horizontal scanline sampling is faster: It lets us +# consider more scanlines while calculating weights for fewer pixels, and +# it reduces our samples from vertical*horizontal to vertical+horizontal. +# This has to come right after ORIG_LINEARIZED, because there's no +# "original_source" scale_type we can use later. +shader2 = "../../crt/shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.slang" +alias2 = "VERTICAL_SCANLINES" +filter_linear2 = "true" +scale_type_x2 = "source" +scale_x2 = "1.0" +scale_type_y2 = "viewport" +scale_y2 = "1.0" +#float_framebuffer2 = "true" +srgb_framebuffer2 = "true" + +# Pass3: Do a small resize blur of ORIG_LINEARIZED at an absolute size, and +# account for convergence offsets. We want to blur a predictable portion of the +# screen to match the phosphor bloom, and absolute scale works best for +# reliable results with a fixed-size bloom. Picking a scale is tricky: +# a.) 400x300 is a good compromise for the "fake-bloom" version: It's low enough +# to blur high-res/interlaced sources but high enough that resampling +# doesn't smear low-res sources too much. +# b.) 320x240 works well for the "real bloom" version: It's 1-1.5% faster, and +# the only noticeable visual difference is a larger halation spread (which +# may be a good thing for people who like to crank it up). +# Note the 4:3 aspect ratio assumes the input has cropped geom_overscan (so it's +# *intended* for an ~4:3 aspect ratio). +shader3 = "../../crt/shaders/crt-royale/src/crt-royale-bloom-approx.slang" +alias3 = "BLOOM_APPROX" +filter_linear3 = "true" +scale_type3 = "absolute" +scale_x3 = "320" +scale_y3 = "240" +srgb_framebuffer3 = "true" + +# Pass4: Vertically blur the input for halation and refractive diffusion. +# Base this on BLOOM_APPROX: This blur should be small and fast, and blurring +# a constant portion of the screen is probably physically correct if the +# viewport resolution is proportional to the simulated CRT size. +shader4 = "../../blurs/blur9fast-vertical.slang" +filter_linear4 = "true" +scale_type4 = "source" +scale4 = "1.0" +srgb_framebuffer4 = "true" + +# Pass5: Horizontally blur the input for halation and refractive diffusion. +# Note: Using a one-pass 9x9 blur is about 1% slower. +shader5 = "../../blurs/blur9fast-horizontal.slang" +alias5 = "HALATION_BLUR" +filter_linear5 = "true" +scale_type5 = "source" +scale5 = "1.0" +srgb_framebuffer5 = "true" + +# Pass6: Lanczos-resize the phosphor mask vertically. Set the absolute +# scale_x5 == mask_texture_small_size.x (see IMPORTANT above). Larger scales +# will blur, and smaller scales could get nasty. The vertical size must be +# based on the viewport size and calculated carefully to avoid artifacts later. +# First calculate the minimum number of mask tiles we need to draw. +# Since curvature is computed after the scanline masking pass: +# num_resized_mask_tiles = 2.0; +# If curvature were computed in the scanline masking pass (it's not): +# max_mask_texel_border = ~3.0 * (1/3.0 + 4.0*sqrt(2.0) + 0.5 + 1.0); +# max_mask_tile_border = max_mask_texel_border/ +# (min_resized_phosphor_triad_size * mask_triads_per_tile); +# num_resized_mask_tiles = max(2.0, 1.0 + max_mask_tile_border * 2.0); +# At typical values (triad_size >= 2.0, mask_triads_per_tile == 8): +# num_resized_mask_tiles = ~3.8 +# Triad sizes are given in horizontal terms, so we need geom_max_aspect_ratio +# to relate them to vertical resolution. The widest we expect is: +# geom_max_aspect_ratio = 4.0/3.0 # Note: Shader passes need to know this! +# The fewer triads we tile across the screen, the larger each triad will be as a +# fraction of the viewport size, and the larger scale_y5 must be to draw a full +# num_resized_mask_tiles. Therefore, we must decide the smallest number of +# triads we'll guarantee can be displayed on screen. We'll set this according +# to 3-pixel triads at 768p resolution (the lowest anyone's likely to use): +# min_allowed_viewport_triads = 768.0*geom_max_aspect_ratio / 3.0 = 341.333333 +# Now calculate the viewport scale that ensures we can draw resized_mask_tiles: +# min_scale_x = resized_mask_tiles * mask_triads_per_tile / +# min_allowed_viewport_triads +# scale_y5 = geom_max_aspect_ratio * min_scale_x +# # Some code might depend on equal scales: +# scale_x6 = scale_y5 +# Given our default geom_max_aspect_ratio and min_allowed_viewport_triads: +# scale_y5 = 4.0/3.0 * 2.0/(341.33333 / 8.0) = 0.0625 +# IMPORTANT: The scales MUST be calculated in this way. If you wish to change +# geom_max_aspect_ratio, update that constant in user-cgp-constants.h! +shader6 = "../../crt/shaders/crt-royale/src/crt-royale-mask-resize-vertical.slang" +filter_linear6 = "true" +scale_type_x6 = "absolute" +scale_x6 = "64" +scale_type_y6 = "viewport" +scale_y6 = "0.0625" # Safe for >= 341.333 horizontal triads at viewport size +#srgb_framebuffer6 = "false" # mask_texture is already assumed linear + +# Pass7: Lanczos-resize the phosphor mask horizontally. scale_x6 = scale_y5. +# TODO: Check again if the shaders actually require equal scales. +shader7 = "../../crt/shaders/crt-royale/src/crt-royale-mask-resize-horizontal.slang" +alias7 = "MASK_RESIZE" +filter_linear7 = "false" +scale_type_x7 = "viewport" +scale_x7 = "0.0625" +scale_type_y7 = "source" +scale_y7 = "1.0" +#srgb_framebuffer7 = "false" # mask_texture is already assumed linear + +# Pass8: Resample (misconverged) scanlines horizontally, apply halation, and +# apply the phosphor mask. +shader8 = "../../crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang" +alias8 = "MASKED_SCANLINES" +filter_linear8 = "true" # This could just as easily be nearest neighbor. +scale_type8 = "viewport" +scale8 = "1.0" +#float_framebuffer8 = "true" +srgb_framebuffer8 = "true" + +# Pass 9: Compute a brightpass. This will require reading the final mask. +shader9 = "../../crt/shaders/crt-royale/src/crt-royale-brightpass.slang" +alias9 = "BRIGHTPASS" +filter_linear9 = "true" # This could just as easily be nearest neighbor. +scale_type9 = "viewport" +scale9 = "1.0" +srgb_framebuffer9 = "true" + +# Pass 10: Blur the brightpass vertically +shader10 = "../../crt/shaders/crt-royale/src/crt-royale-bloom-vertical.slang" +filter_linear10 = "true" # This could just as easily be nearest neighbor. +scale_type10 = "source" +scale10 = "1.0" +srgb_framebuffer10 = "true" + +# Pass 11: Blur the brightpass horizontally and combine it with the dimpass: +shader11 = "../../crt/shaders/crt-royale/src/crt-royale-bloom-horizontal-reconstitute.slang" +filter_linear11 = "true" +scale_type11 = "source" +scale11 = "1.0" +srgb_framebuffer11 = "true" + +# Pass 12: Compute curvature/AA: +shader12 = "../../crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.slang" +filter_linear12 = "true" +scale_type12 = "viewport" +mipmap_input12 = "true" +texture_wrap_mode12 = "clamp_to_edge" + diff --git a/border/sgb/sgb-gbc-color-tvout+interlacing.slangp b/border/sgb/sgb-gbc-color-tvout+interlacing.slangp new file mode 100644 index 0000000..69d430f --- /dev/null +++ b/border/sgb/sgb-gbc-color-tvout+interlacing.slangp @@ -0,0 +1,32 @@ +shaders = "5" +shader0 = "../../handheld/shaders/color/gbc-color.slang" +shader1 = "../shaders/imgborder-sgb.slang" +shader2 = "../../crt/shaders/tvout-tweaks.slang" +shader3 = "../../misc/image-adjustment.slang" +shader4 = "../../misc/interlacing.slang" + +filter_linear0 = false +scale_type_0 = source +scale0 = 1.0 + +scale_type_x1 = "absolute" +scale_x1 = "256" +scale_type_y1 = "absolute" +scale_y1 = "224" + +scale_type_x2 = "viewport" +scale_x2 = "1.000000" +scale_type_y2 = "source" +scale_y2 = "1.000000" + +parameters = "box_scale;location;in_res_x;in_res_y;TVOUT_RESOLUTION;TVOUT_COMPOSITE_CONNECTION;TVOUT_TV_COLOR_LEVELS" +box_scale = "1.000000" +location = "0.500000" +in_res_x = "160.000000" +in_res_y = "144.000000" +TVOUT_RESOLUTION = "320.000000" +TVOUT_COMPOSITE_CONNECTION = "0.000000" +TVOUT_TV_COLOR_LEVELS = "0.000000" + +textures = "BORDER" +BORDER = "sgb.png" diff --git a/border/sgb/sgb-gbc-color.slangp b/border/sgb/sgb-gbc-color.slangp new file mode 100644 index 0000000..6cd45d0 --- /dev/null +++ b/border/sgb/sgb-gbc-color.slangp @@ -0,0 +1,21 @@ +shaders = "2" +shader0 = "../../handheld/shaders/color/gbc-color.slang" +shader1 = "../shaders/imgborder-sgb.slang" + +filter_linear0 = false +scale_type_0 = source +scale0 = 1.0 + +scale_type_x1 = "absolute" +scale_x1 = "256" +scale_type_y1 = "absolute" +scale_y1 = "224" + +parameters = "box_scale;location;in_res_x;in_res_y" +box_scale = "1.000000" +location = "0.500000" +in_res_x = "160.000000" +in_res_y = "144.000000" + +textures = "BORDER" +BORDER = "sgb.png" diff --git a/border/sgb/sgb-tvout+interlacing.slangp b/border/sgb/sgb-tvout+interlacing.slangp new file mode 100644 index 0000000..e793fab --- /dev/null +++ b/border/sgb/sgb-tvout+interlacing.slangp @@ -0,0 +1,27 @@ +shaders = "4" +shader0 = "../shaders/imgborder-sgb.slang" +shader1 = "../../crt/shaders/tvout-tweaks.slang" +shader2 = "../../misc/image-adjustment.slang" +shader3 = "../../misc/interlacing.slang" + +scale_type_x0 = "absolute" +scale_x0 = "256" +scale_type_y0 = "absolute" +scale_y0 = "224" + +scale_type_x1 = "viewport" +scale_x1 = "1.000000" +scale_type_y1 = "source" +scale_y1 = "1.000000" + +parameters = "box_scale;location;in_res_x;in_res_y;TVOUT_RESOLUTION;TVOUT_COMPOSITE_CONNECTION;TVOUT_TV_COLOR_LEVELS" +box_scale = "1.000000" +location = "0.500000" +in_res_x = "160.000000" +in_res_y = "144.000000" +TVOUT_RESOLUTION = "320.000000" +TVOUT_COMPOSITE_CONNECTION = "0.000000" +TVOUT_TV_COLOR_LEVELS = "0.000000" + +textures = "BORDER" +BORDER = "sgb.png" diff --git a/border/sgba/sgba-tvout+interlacing.slangp b/border/sgba/sgba-tvout+interlacing.slangp new file mode 100644 index 0000000..2ec7f00 --- /dev/null +++ b/border/sgba/sgba-tvout+interlacing.slangp @@ -0,0 +1,27 @@ +shaders = "4" +shader0 = "../shaders/imgborder-sgba.slang" +shader1 = "../../crt/shaders/tvout-tweaks.slang" +shader2 = "../../misc/image-adjustment.slang" +shader3 = "../../misc/interlacing.slang" + +scale_type_x0 = "absolute" +scale_x0 = "320" +scale_type_y0 = "absolute" +scale_y0 = "240" + +scale_type_x1 = "viewport" +scale_x1 = "1.000000" +scale_type_y1 = "source" +scale_y1 = "1.000000" + +parameters = "box_scale;location;in_res_x;in_res_y;TVOUT_RESOLUTION;TVOUT_COMPOSITE_CONNECTION;TVOUT_TV_COLOR_LEVELS" +box_scale = "1.000000" +location = "0.500000" +in_res_x = "240.000000" +in_res_y = "160.000000" +TVOUT_RESOLUTION = "512.000000" +TVOUT_COMPOSITE_CONNECTION = "0.000000" +TVOUT_TV_COLOR_LEVELS = "1.000000" + +textures = "BORDER" +BORDER = "sgba.png" diff --git a/border/sgba/sgba-tvout-gba-color+interlacing.slangp b/border/sgba/sgba-tvout-gba-color+interlacing.slangp new file mode 100644 index 0000000..dcbfdcb --- /dev/null +++ b/border/sgba/sgba-tvout-gba-color+interlacing.slangp @@ -0,0 +1,31 @@ +shaders = "5" +shader0 = "../../handheld/shaders/color/gba-color.slang" +shader1 = "../shaders/imgborder-sgba.slang" +shader2 = "../../crt/shaders/tvout-tweaks.slang" +shader3 = "../../misc/image-adjustment.slang" +shader4 = "../../misc/interlacing.slang" + +scale_type0 = "source" +scale0 = "1.0" + +scale_type_x1 = "absolute" +scale_x1 = "320" +scale_type_y1 = "absolute" +scale_y1 = "240" + +scale_type_x2 = "viewport" +scale_x2 = "1.000000" +scale_type_y2 = "source" +scale_y2 = "1.000000" + +parameters = "box_scale;location;in_res_x;in_res_y;TVOUT_RESOLUTION;TVOUT_COMPOSITE_CONNECTION;TVOUT_TV_COLOR_LEVELS" +box_scale = "1.000000" +location = "0.500000" +in_res_x = "240.000000" +in_res_y = "160.000000" +TVOUT_RESOLUTION = "512.000000" +TVOUT_COMPOSITE_CONNECTION = "0.000000" +TVOUT_TV_COLOR_LEVELS = "1.000000" + +textures = "BORDER" +BORDER = "sgba.png"