slang-shaders/bezel/Mega_Bezel/shaders/base/text-resolution.inc

478 lines
15 KiB
PHP
Raw Normal View History

2022-06-25 10:06:45 +10:00
/*
Text code is from the Shadertoy "96-bit 8x12" Font by Flyguy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "text-lib.inc"
2022-06-25 10:06:45 +10:00
float DrawResolutions(vec2 uv, vec2 viewport_size, vec2 screen_size, vec2 derezed_size, vec2 negative_crop_added_size, vec2 cropped_original_size, vec2 sampling_res, vec2 int_mult)
{
float col = 0.0;
float current_line_index = 0;
float margin = STRHEIGHT(1);
//Resolution Text
printPos = vec2(margin, 0);
TEXT_MODE = NORMAL;
// Line 14 Viewport Resolution ----------------------------------------------------
printPos.x = margin;
printPos.y += STRHEIGHT(1);
TEXT_MODE = NORMAL;
col += GetChar(ch_V, uv);
col += GetChar(ch_i, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_w, uv);
col += GetChar(ch_p, uv);
col += GetChar(ch_o, uv);
col += GetChar(ch_r, uv);
col += GetChar(ch_t, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_spc, uv);
col += print_integer(viewport_size.x,0, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_x, uv);
col += GetChar(ch_spc, uv);
col += print_integer(viewport_size.y,0, uv);
// Line 13 Screen Resolution ----------------------------------------------------------
printPos.x = margin;
printPos.y += STRHEIGHT(1);
col += GetChar(ch_S, uv);
col += GetChar(ch_c, uv);
col += GetChar(ch_r, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_n, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_spc, uv);
col += print_integer(screen_size.x,0, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_x, uv);
col += GetChar(ch_spc, uv);
col += print_integer(screen_size.y,0, uv);
// Line 12 Final Aspect Ratio ----------------------------------------------------------
printPos.x = margin;
printPos.y += STRHEIGHT(1);
col += GetChar(ch_F, uv);
col += GetChar(ch_i, uv);
col += GetChar(ch_n, uv);
col += GetChar(ch_a, uv);
col += GetChar(ch_l, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_A, uv);
col += GetChar(ch_s, uv);
col += GetChar(ch_p, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_c, uv);
col += GetChar(ch_t, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_spc, uv);
col += print_number(screen_size.x/screen_size.y > 1 ? screen_size.x/screen_size.y : screen_size.y/screen_size.x, uv, 2);
// Line 11 Non-Int Scale Percent ----------------------------------------------------------
printPos.x = margin;
printPos.y += STRHEIGHT(1);
col += GetChar(ch_N, uv);
col += GetChar(ch_o, uv);
col += GetChar(ch_n, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_I, uv);
col += GetChar(ch_n, uv);
col += GetChar(ch_t, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_S, uv);
col += GetChar(ch_c, uv);
col += GetChar(ch_l, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_pct, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_spc, uv);
col += print_number(screen_size.y / viewport_size.y * 100, uv, 3);
// Line 10 Int Scale Vertical ----------------------------------------------------------
printPos.x = margin;
printPos.y += STRHEIGHT(1);
col += GetChar(ch_I, uv);
col += GetChar(ch_n, uv);
col += GetChar(ch_t, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_S, uv);
col += GetChar(ch_c, uv);
col += GetChar(ch_l, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_V, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_r, uv);
col += GetChar(ch_t, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_spc, uv);
Mega Bezel update to V1.0.003_2022-07-28_Rev-1 * Updated to the latest guest release: crt-guest-advanced-2022-07-27-release1 * Changed Guest mask size to 1 by default so that there isn't inconsistency using guest settings in the Mega Bezel * Adjusted the default SMOOTH-ADV scaling parameters for a sharper smooth look: * HSM_CORE_RES_SAMPLING_MULT_SCANLINE_DIR = 300 * HSM_CORE_RES_SAMPLING_MULT_OPPOSITE_DIR = 125 * HSM_DOWNSAMPLE_BLUR_SCANLINE_DIR = 0 * HSM_DOWNSAMPLE_BLUR_OPPOSITE_DIR = 0 * Added **Shift Sampling Relative to Scanlines** to shift the image relative to the scanlines * The ScaleFx settings now only appear on the SMOOTH-ADV preset nearer the bottom of the parameter list * Fixed Double image when using cropping in NTSC presets reported by @JHorbach1 * Updated to crt-guest-advanced-2022-07-17-release1 * Includes Scanline Gamma * Tube Gel and Diffuse Fixes * Gel is now mapped to the tube, independent of the black edge * Added a feature to add a bit of tube diffuse shading to the GEL this should make it look a little more natural * [ TUBE COLORED GEL IMAGE ] > Normal Multiply by Tube Diffuse Shading * HSM_TUBE_BLACK_EDGE_LAYERING_MODE has been removed as it's not needed anymore * CRT Multiply blend mode now works better when there is extra tube thickness * Changed HSM_TUBE_DIFFUSE_IMAGE_SCALE to 120 by default to have a less rounded look * If you want a stronger rounded shaded look reset it to 100 * Fixed Scale discrepancy when using the Cab Glass Image * Added Shadow Opacity param to control shadow being applied to the static tube highlight
2022-07-29 11:56:28 +10:00
if (fract(int_mult.y) < 0.01 || fract(int_mult.y) > 0.99)
col += print_number(int_mult.y, uv, 0);
else
col += print_number(int_mult.y, uv, 3);
2022-06-25 10:06:45 +10:00
// Line 09 Int Scale Horizontal ----------------------------------------------------------
printPos.x = margin;
printPos.y += STRHEIGHT(1);
col += GetChar(ch_I, uv);
col += GetChar(ch_n, uv);
col += GetChar(ch_t, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_S, uv);
col += GetChar(ch_c, uv);
col += GetChar(ch_l, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_H, uv);
col += GetChar(ch_o, uv);
col += GetChar(ch_r, uv);
col += GetChar(ch_z, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_spc, uv);
Mega Bezel update to V1.0.003_2022-07-28_Rev-1 * Updated to the latest guest release: crt-guest-advanced-2022-07-27-release1 * Changed Guest mask size to 1 by default so that there isn't inconsistency using guest settings in the Mega Bezel * Adjusted the default SMOOTH-ADV scaling parameters for a sharper smooth look: * HSM_CORE_RES_SAMPLING_MULT_SCANLINE_DIR = 300 * HSM_CORE_RES_SAMPLING_MULT_OPPOSITE_DIR = 125 * HSM_DOWNSAMPLE_BLUR_SCANLINE_DIR = 0 * HSM_DOWNSAMPLE_BLUR_OPPOSITE_DIR = 0 * Added **Shift Sampling Relative to Scanlines** to shift the image relative to the scanlines * The ScaleFx settings now only appear on the SMOOTH-ADV preset nearer the bottom of the parameter list * Fixed Double image when using cropping in NTSC presets reported by @JHorbach1 * Updated to crt-guest-advanced-2022-07-17-release1 * Includes Scanline Gamma * Tube Gel and Diffuse Fixes * Gel is now mapped to the tube, independent of the black edge * Added a feature to add a bit of tube diffuse shading to the GEL this should make it look a little more natural * [ TUBE COLORED GEL IMAGE ] > Normal Multiply by Tube Diffuse Shading * HSM_TUBE_BLACK_EDGE_LAYERING_MODE has been removed as it's not needed anymore * CRT Multiply blend mode now works better when there is extra tube thickness * Changed HSM_TUBE_DIFFUSE_IMAGE_SCALE to 120 by default to have a less rounded look * If you want a stronger rounded shaded look reset it to 100 * Fixed Scale discrepancy when using the Cab Glass Image * Added Shadow Opacity param to control shadow being applied to the static tube highlight
2022-07-29 11:56:28 +10:00
if (fract(int_mult.x) < 0.01 || fract(int_mult.x) > 0.99)
col += print_number(int_mult.x, uv, 0);
else
col += print_number(int_mult.x, uv, 3);
2022-06-25 10:06:45 +10:00
// Line 08 Sampling Resolution ----------------------------------------------------------
if (cropped_original_size.x != sampling_res.x || cropped_original_size.y != sampling_res.y)
{
printPos.x = margin;
printPos.y += STRHEIGHT(1);
col += GetChar(ch_S, uv);
col += GetChar(ch_a, uv);
col += GetChar(ch_m, uv);
col += GetChar(ch_p, uv);
col += GetChar(ch_l, uv);
col += GetChar(ch_i, uv);
col += GetChar(ch_n, uv);
col += GetChar(ch_g, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_R, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_s, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_spc, uv);
col += print_integer(sampling_res.x,0, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_x, uv);
col += GetChar(ch_spc, uv);
col += print_integer(sampling_res.y,0, uv);
}
// Line 07 CROPPED Resolution ----------------------------------------------------------
if (cropped_original_size.x != ROTATED_CORE_PREPPED_SIZE.x || cropped_original_size.y != ROTATED_CORE_PREPPED_SIZE.y)
{
printPos.x = margin;
printPos.y += STRHEIGHT(1);
col += GetChar(ch_C, uv);
col += GetChar(ch_r, uv);
col += GetChar(ch_o, uv);
col += GetChar(ch_p, uv);
col += GetChar(ch_p, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_d, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_spc, uv);
col += print_integer(cropped_original_size.x,0, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_x, uv);
col += GetChar(ch_spc, uv);
col += print_integer(cropped_original_size.y,0, uv);
}
// Line 06 Negative Crop Resolution ----------------------------------------------------------
if (derezed_size.x != ROTATED_CORE_PREPPED_SIZE.x || derezed_size.y != ROTATED_CORE_PREPPED_SIZE.y)
{
printPos.x = margin;
printPos.y += STRHEIGHT(1);
col += GetChar(ch_N, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_g, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_C, uv);
col += GetChar(ch_r, uv);
col += GetChar(ch_o, uv);
col += GetChar(ch_p, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_A, uv);
col += GetChar(ch_d, uv);
col += GetChar(ch_d, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_spc, uv);
col += print_integer(ROTATED_CORE_PREPPED_SIZE.x,0, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_x, uv);
col += GetChar(ch_spc, uv);
col += print_integer(ROTATED_CORE_PREPPED_SIZE.y,0, uv);
}
// Line 05 DEREZ Resolution ----------------------------------------------------------
if (derezed_size.x != ROTATED_CORE_ORIGINAL_SIZE.x || derezed_size.y != ROTATED_CORE_ORIGINAL_SIZE.y)
{
printPos.x = margin;
printPos.y += STRHEIGHT(1);
col += GetChar(ch_D, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_r, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_z, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_d, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_spc, uv);
col += print_integer(derezed_size.x,0, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_x, uv);
col += GetChar(ch_spc, uv);
col += print_integer(derezed_size.y,0, uv);
}
// Line 04 CORE Resolution ----------------------------------------------------------
printPos.x = margin;
printPos.y += STRHEIGHT(1);
col += GetChar(ch_C, uv);
col += GetChar(ch_o, uv);
col += GetChar(ch_r, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_spc, uv);
col += print_integer(ROTATED_CORE_ORIGINAL_SIZE.x,0, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_x, uv);
col += GetChar(ch_spc, uv);
col += print_integer(ROTATED_CORE_ORIGINAL_SIZE.y,0, uv);
// Line 03 Preset Type ----------------------------------------------------------
printPos.x = margin;
printPos.y += STRHEIGHT(2);
#ifdef IS_ADV_PRESET
col += GetChar(ch_A, uv);
col += GetChar(ch_D, uv);
col += GetChar(ch_V, uv);
col += GetChar(ch_A, uv);
col += GetChar(ch_N, uv);
col += GetChar(ch_C, uv);
col += GetChar(ch_E, uv);
col += GetChar(ch_D, uv);
#endif
#ifdef IS_STD_PRESET
col += GetChar(ch_S, uv);
col += GetChar(ch_T, uv);
col += GetChar(ch_A, uv);
col += GetChar(ch_N, uv);
col += GetChar(ch_D, uv);
col += GetChar(ch_A, uv);
col += GetChar(ch_R, uv);
col += GetChar(ch_D, uv);
#endif
#ifdef IS_GLASS_PRESET
col += GetChar(ch_spc, uv);
col += GetChar(ch_G, uv);
col += GetChar(ch_L, uv);
col += GetChar(ch_A, uv);
col += GetChar(ch_S, uv);
col += GetChar(ch_S, uv);
#endif
#ifdef IS_NO_REFLECT_PRESET
col += GetChar(ch_spc, uv);
col += GetChar(ch_N, uv);
col += GetChar(ch_O, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_R, uv);
col += GetChar(ch_E, uv);
col += GetChar(ch_F, uv);
col += GetChar(ch_L, uv);
col += GetChar(ch_E, uv);
col += GetChar(ch_C, uv);
col += GetChar(ch_T, uv);
#endif
#ifdef IS_POTATO_PRESET
col += GetChar(ch_P, uv);
col += GetChar(ch_0, uv);
col += GetChar(ch_T, uv);
col += GetChar(ch_A, uv);
col += GetChar(ch_T, uv);
col += GetChar(ch_O, uv);
#endif
// Line 02 Version ----------------------------------------------------------
printPos.x = margin;
printPos.y += STRHEIGHT(1);
col += GetChar(ch_1, uv);
col += GetChar(ch_per, uv);
col += GetChar(ch_0, uv);
col += GetChar(ch_per, uv);
col += GetChar(ch_0, uv);
col += GetChar(ch_0, uv);
col += GetChar(ch_7, uv);
2022-06-25 10:06:45 +10:00
col += GetChar(ch_spc, uv);
// Date
col += GetChar(ch_2, uv);
col += GetChar(ch_0, uv);
col += GetChar(ch_2, uv);
col += GetChar(ch_2, uv);
col += GetChar(ch_dsh, uv);
col += GetChar(ch_0, uv);
col += GetChar(ch_8, uv);
2022-06-25 10:06:45 +10:00
col += GetChar(ch_dsh, uv);
col += GetChar(ch_2, uv);
col += GetChar(ch_9, uv);
2022-06-25 10:06:45 +10:00
// Revision
col += GetChar(ch_spc, uv);
col += GetChar(ch_R, uv);
col += GetChar(ch_e, uv);
col += GetChar(ch_v, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_1, uv);
// Line 01 Title ----------------------------------------------------------
printPos.x = margin;
printPos.y += STRHEIGHT(1);
col += GetChar(ch_M, uv);
col += GetChar(ch_E, uv);
col += GetChar(ch_G, uv);
col += GetChar(ch_A, uv);
col += GetChar(ch_spc, uv);
col += GetChar(ch_B, uv);
col += GetChar(ch_E, uv);
col += GetChar(ch_Z, uv);
col += GetChar(ch_E, uv);
col += GetChar(ch_L, uv);
col += GetChar(ch_spc, uv);
TEXT_MODE = NORMAL;
return col;
}
// Returns a
float GetTextMask(vec2 in_coord, vec2 viewport_size, vec2 screen_size, vec2 derezed_size, vec2 negative_crop_added_size, vec2 cropped_original_size, vec2 sampling_res, vec2 int_mult, vec2 canvas_size)
{
in_coord = (in_coord - 0.5) * vec2(1, -1) + 0.5;
float downscale = 1;
if (canvas_size.y > 600) downscale = 2;
if (canvas_size.y > 1000) downscale = 3;
textCanvasResolution = global.OutputSize.xy / downscale;
vec2 uv = global.OutputSize.xy * in_coord;
vec2 downscaled_uv = floor(global.OutputSize.xy * in_coord / downscale);
float pixel = DrawResolutions(downscaled_uv, viewport_size, screen_size, derezed_size, negative_crop_added_size, cropped_original_size, sampling_res, int_mult);
vec3 col = vec3(1);
pixel *= (1 - distance(mod(uv, vec2(1.0)), vec2(0.65))) * 1.2;
col *= mix(vec3(0), vec3(1, 1, 1), pixel);
return col.r;
}