diff --git a/crt/shaders/crt-royale/src/crt-royale-bloom-approx.slang b/crt/shaders/crt-royale/src/crt-royale-bloom-approx.slang index ed20598..f803064 100644 --- a/crt/shaders/crt-royale/src/crt-royale-bloom-approx.slang +++ b/crt/shaders/crt-royale/src/crt-royale-bloom-approx.slang @@ -42,8 +42,6 @@ layout(push_constant) uniform Push /////////////////////////////////// HELPERS ////////////////////////////////// -/////////////////////////////////// HELPERS ////////////////////////////////// - vec3 tex2Dresize_gaussian4x4(const sampler2D tex, const vec2 tex_uv, const vec2 dxdy, const vec2 texture_size, const vec2 texture_size_inv, const vec2 tex_uv_to_pixel_scale, const float sigma) @@ -268,7 +266,7 @@ void main() const vec2 texture_size = registers.ORIG_LINEARIZEDSize.xy; vec2 tex_uv_r, tex_uv_g, tex_uv_b; - if(beam_misconvergence = true) + if(beam_misconvergence == true) { const vec2 convergence_offsets_r = get_convergence_offsets_r_vector(); const vec2 convergence_offsets_g = get_convergence_offsets_g_vector(); @@ -288,7 +286,7 @@ void main() if(bloom_approx_filter > 1.5) { // Use a 4x4 Gaussian resize. This is slower but technically correct. - if(beam_misconvergence = true) + if(beam_misconvergence == true) { color_r = tex2Dresize_gaussian4x4(ORIG_LINEARIZED, tex_uv_r, blur_dxdy, texture_size, texture_size_inv, @@ -312,7 +310,7 @@ void main() // Use a 3x3 resize blur. This is the softest option, because we're // blurring already blurry bilinear samples. It doesn't play quite as // nicely with convergence offsets, but it has its charms. - if(beam_misconvergence = true) + if(beam_misconvergence == true) { color_r = tex2Dblur3x3resize(ORIG_LINEARIZED, tex_uv_r, blur_dxdy, bloom_approx_sigma); @@ -334,7 +332,7 @@ void main() // too sharp above ~400x300, but the blurs break down above that // resolution too, unless min_allowed_viewport_triads is high enough to // keep bloom_approx_scale_x/min_allowed_viewport_triads < ~1.1658025.) - if(beam_misconvergence = true) + if(beam_misconvergence == true) { color_r = tex2D_linearize(ORIG_LINEARIZED, tex_uv_r).rgb; color_g = tex2D_linearize(ORIG_LINEARIZED, tex_uv_g).rgb; @@ -346,7 +344,7 @@ void main() } } // Pack the colors from the red/green/blue beams into a single vector: - if(beam_misconvergence = true) + if(beam_misconvergence == true) { color = vec3(color_r.r, color_g.g, color_b.b); } diff --git a/crt/shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.slang b/crt/shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.slang index 888fc04..d9cc61f 100644 --- a/crt/shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.slang +++ b/crt/shaders/crt-royale/src/crt-royale-first-pass-linearize-crt-gamma-bob-fields.slang @@ -79,7 +79,7 @@ void main() // Linearize the input based on CRT gamma and bob interlaced fields. // Bobbing ensures we can immediately blur without getting artifacts. // Note: TFF/BFF won't matter for sources that double-weave or similar. -if(interlace_detect) +if(interlace_detect == true) { // Sample the current line and an average of the previous/next line; // tex2D_linearize will decode CRT gamma. Don't bother branching: diff --git a/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass-backup.slang b/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass-backup.slang index 06f730a..2e4466e 100644 --- a/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass-backup.slang +++ b/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass-backup.slang @@ -226,7 +226,7 @@ void main() // Sample the input with antialiasing (due to sharp phosphors, etc.): color = tex2Daa(Source, tex_uv, pixel_to_tex_uv, registers.FrameCount); } - else if(aa_level > 0.5 && need_subpixel_aa == true) + else if(aa_level > 0.5 && need_subpixel_aa = true) { // Sample at each subpixel location: color = tex2Daa_subpixel_weights_only( diff --git a/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang b/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang index 2dd4f17..e7a7949 100644 --- a/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang +++ b/crt/shaders/crt-royale/src/crt-royale-scanlines-horizontal-apply-mask.slang @@ -161,7 +161,7 @@ void main() const bool sample_orig_luts = true; #endif - if(sample_orig_luts = true) + if(sample_orig_luts == true) { // If mask_type is static, this branch will be resolved statically. if(params.mask_type < 0.5) diff --git a/crt/shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.slang b/crt/shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.slang index 6209870..563ea39 100644 --- a/crt/shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.slang +++ b/crt/shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.slang @@ -110,7 +110,7 @@ void main() scanline_outside_color; float dist_round; // Use scanlines 0, 1, 4, and 5 for a total of 6 scanlines: - if(beam_num_scanlines > 5.5) + if(params.beam_num_scanlines > 5.5) { scanline1_color = tex2D_linearize(Source, scanline_uv - v_step).rgb; @@ -122,7 +122,7 @@ void main() tex2D_linearize(Source, scanline_uv + 3.0 * v_step).rgb; } // Use scanlines 1, 4, and either 0 or 5 for a total of 5 scanlines: - else if(beam_num_scanlines > 4.5) + else if(params.beam_num_scanlines > 4.5) { scanline1_color = tex2D_linearize(Source, scanline_uv - v_step).rgb; @@ -138,7 +138,7 @@ void main() Source, scanline_uv + sample_0_or_5_uv_off).rgb; } // Use scanlines 1 and 4 for a total of 4 scanlines: - else if(beam_num_scanlines > 3.5) + else if(params.beam_num_scanlines > 3.5) { scanline1_color = tex2D_linearize(Source, scanline_uv - v_step).rgb; @@ -146,7 +146,7 @@ void main() tex2D_linearize(Source, scanline_uv + 2.0 * v_step).rgb; } // Use scanline 1 or 4 for a total of 3 scanlines: - else if(beam_num_scanlines > 2.5) + else if(params.beam_num_scanlines > 2.5) { // dist is in [0, 1] dist_round = round(dist); @@ -160,7 +160,7 @@ void main() // Vertical convergence offsets are in units of current-field scanlines. // dist2 means "positive sample distance from scanline 2, in scanlines:" vec3 dist2 = vec3(dist); - if(beam_misconvergence = true) + if(beam_misconvergence == true) { const vec3 convergence_offsets_vert_rgb = get_convergence_offsets_y_vector(); @@ -182,7 +182,7 @@ void main() scanline3_color, ph, sigma_range, shape_range); vec3 scanline_intensity = scanline2_contrib + scanline3_contrib; - if(beam_num_scanlines > 5.5) + if(params.beam_num_scanlines > 5.5) { vec3 scanline0_contrib = scanline_contrib(dist2 + vec3(2.0), scanline0_color, @@ -199,7 +199,7 @@ void main() scanline_intensity += scanline0_contrib + scanline1_contrib + scanline4_contrib + scanline5_contrib; } - else if(beam_num_scanlines > 4.5) + else if(params.beam_num_scanlines > 4.5) { vec3 scanline1_contrib = scanline_contrib(dist2 + vec3(1.0), scanline1_color, @@ -214,7 +214,7 @@ void main() scanline_intensity += scanline1_contrib + scanline4_contrib + scanline0or5_contrib; } - else if(beam_num_scanlines > 3.5) + else if(params.beam_num_scanlines > 3.5) { vec3 scanline1_contrib = scanline_contrib(dist2 + vec3(1.0), scanline1_color, @@ -224,7 +224,7 @@ void main() ph, sigma_range, shape_range); scanline_intensity += scanline1_contrib + scanline4_contrib; } - else if(beam_num_scanlines > 2.5) + else if(params.beam_num_scanlines > 2.5) { vec3 dist1or4 = mix( dist2 + vec3(1.0), vec3(2.0) - dist2, dist_round); diff --git a/crt/shaders/crt-royale/src/geometry-functions.h b/crt/shaders/crt-royale/src/geometry-functions.h index 8516da9..de8036a 100644 --- a/crt/shaders/crt-royale/src/geometry-functions.h +++ b/crt/shaders/crt-royale/src/geometry-functions.h @@ -630,7 +630,7 @@ vec2 get_curved_video_uv_coords_and_tangent_matrix( #else // Manually define a transformation matrix. We'll assume pixel-space // +y = down, just like +v = down. - if(geom_force_correct_tangent_matrix) + if(geom_force_correct_tangent_matrix == true) { // Get the surface normal based on the local intersection position: vec3 normal_base = pos; diff --git a/crt/shaders/crt-royale/src/params.inc b/crt/shaders/crt-royale/src/params.inc index 26374e1..e442b5e 100644 --- a/crt/shaders/crt-royale/src/params.inc +++ b/crt/shaders/crt-royale/src/params.inc @@ -33,21 +33,22 @@ layout(std140, set = 0, binding = 0) uniform UBO float mask_num_triads_desired; // float aa_subpixel_r_offset_x_runtime; // float aa_subpixel_r_offset_y_runtime; - float aa_cubic_c; - float aa_gauss_sigma; - float geom_mode_runtime; - float geom_radius; - float geom_view_dist; - float geom_tilt_angle_x; - float geom_tilt_angle_y; +// float aa_cubic_c; +// float aa_gauss_sigma; +// float geom_mode_runtime; +// float geom_radius; +// float geom_view_dist; +// float geom_tilt_angle_x; +// float geom_tilt_angle_y; float geom_aspect_ratio_x; float geom_aspect_ratio_y; - float geom_overscan_x; - float geom_overscan_y; - float border_size; - float border_darkness; - float border_compress; +// float geom_overscan_x; +// float geom_overscan_y; +// float border_size; +// float border_darkness; +// float border_compress; float interlace_1080i; + float beam_num_scanlines; } params; // Set shader params for all passes here: @@ -74,26 +75,27 @@ layout(std140, set = 0, binding = 0) uniform UBO #pragma parameter convergence_offset_y_g "convergence_offset_y_g" 0.0 -2.0 2.0 0.05 #pragma parameter convergence_offset_y_b "convergence_offset_y_b" 0.0 -2.0 2.0 0.05 #pragma parameter mask_type "mask_type" 1.0 0.0 2.0 1.0 -#pragma parameter mask_sample_mode_desired "mask_sample_mode" 0.0 0.0 2.0 1.0 // Consider blocking mode 2. +#pragma parameter mask_sample_mode_desired "mask_sample_mode" 1.0 0.0 2.0 1.0 // Consider blocking mode 2. #pragma parameter mask_specify_num_triads "mask_specify_num_triads" 0.0 0.0 1.0 1.0 #pragma parameter mask_triad_size_desired "mask_triad_size_desired" 3.0 1.0 18.0 0.125 #pragma parameter mask_num_triads_desired "mask_num_triads_desired" 480.0 342.0 1920.0 1.0 //#pragma parameter aa_subpixel_r_offset_x_runtime "aa_subpixel_r_offset_x" -0.333333333 -0.333333333 0.333333333 0.333333333 //#pragma parameter aa_subpixel_r_offset_y_runtime "aa_subpixel_r_offset_y" 0.0 -0.333333333 0.333333333 0.333333333 -#pragma parameter aa_cubic_c "antialias_cubic_sharpness" 0.5 0.0 4.0 0.015625 -#pragma parameter aa_gauss_sigma "antialias_gauss_sigma" 0.5 0.0625 1.0 0.015625 -#pragma parameter geom_mode_runtime "geom_mode" 0.0 0.0 3.0 1.0 -#pragma parameter geom_radius "geom_radius" 2.0 0.16 1024.0 0.1 -#pragma parameter geom_view_dist "geom_view_dist" 2.0 0.5 1024.0 0.25 -#pragma parameter geom_tilt_angle_x "geom_tilt_angle_x" 0.0 -3.14159265 3.14159265 0.017453292519943295 -#pragma parameter geom_tilt_angle_y "geom_tilt_angle_y" 0.0 -3.14159265 3.14159265 0.017453292519943295 +//#pragma parameter aa_cubic_c "antialias_cubic_sharpness" 0.5 0.0 4.0 0.015625 +//#pragma parameter aa_gauss_sigma "antialias_gauss_sigma" 0.5 0.0625 1.0 0.015625 +//#pragma parameter geom_mode_runtime "geom_mode" 0.0 0.0 3.0 1.0 +//#pragma parameter geom_radius "geom_radius" 2.0 0.16 1024.0 0.1 +//#pragma parameter geom_view_dist "geom_view_dist" 2.0 0.5 1024.0 0.25 +//#pragma parameter geom_tilt_angle_x "geom_tilt_angle_x" 0.0 -3.14159265 3.14159265 0.017453292519943295 +//#pragma parameter geom_tilt_angle_y "geom_tilt_angle_y" 0.0 -3.14159265 3.14159265 0.017453292519943295 #pragma parameter geom_aspect_ratio_x "geom_aspect_ratio_x" 432.0 1.0 512.0 1.0 #pragma parameter geom_aspect_ratio_y "geom_aspect_ratio_y" 329.0 1.0 512.0 1.0 -#pragma parameter geom_overscan_x "geom_overscan_x" 1.0 0.00390625 4.0 0.00390625 -#pragma parameter geom_overscan_y "geom_overscan_y" 1.0 0.00390625 4.0 0.00390625 -#pragma parameter border_size "border_size" 0.015 0.0000001 0.5 0.005 -#pragma parameter border_darkness "border_darkness" 2.0 0.0 16.0 0.0625 -#pragma parameter border_compress "border_compress" 2.5 1.0 64.0 0.0625 +//#pragma parameter geom_overscan_x "geom_overscan_x" 1.0 0.00390625 4.0 0.00390625 +//#pragma parameter geom_overscan_y "geom_overscan_y" 1.0 0.00390625 4.0 0.00390625 +//#pragma parameter border_size "border_size" 0.015 0.0000001 0.5 0.005 +//#pragma parameter border_darkness "border_darkness" 2.0 0.0 16.0 0.0625 +//#pragma parameter border_compress "border_compress" 2.5 1.0 64.0 0.0625 #pragma parameter interlace_1080i "interlace_1080i" 0.0 0.0 1.0 1.0 +#pragma parameter beam_num_scanlines "beam_num_scanlines" 4.0 2.0 6.0 1.0 #endif \ No newline at end of file diff --git a/crt/shaders/crt-royale/src/scanline-functions.h b/crt/shaders/crt-royale/src/scanline-functions.h index 0f6612e..ede23d8 100644 --- a/crt/shaders/crt-royale/src/scanline-functions.h +++ b/crt/shaders/crt-royale/src/scanline-functions.h @@ -214,7 +214,7 @@ vec3 sample_single_scanline_horizontal(const sampler2D texture, bool is_interlaced(float num_lines) { // Detect interlacing based on the number of lines in the source. - if(interlace_detect = true) + if(interlace_detect == true) { // NTSC: 525 lines, 262.5/field; 486 active (2 half-lines), 243/field // NTSC Emulators: Typically 224 or 240 lines @@ -252,7 +252,7 @@ vec3 sample_rgb_scanline_horizontal(const sampler2D tex, { // TODO: Add function requirements. // Rely on a helper to make convergence easier. - if(beam_misconvergence = true) + if(beam_misconvergence == true) { const vec3 convergence_offsets_rgb = get_convergence_offsets_x_vector(); @@ -539,7 +539,7 @@ vec3 scanline_contrib(vec3 dist, vec3 color, // Returns: Return a scanline's light output over a given pixel, using // a generalized or pure Gaussian distribution and sampling or // integrals as desired by user codepath choices. - if(beam_generalized_gaussian = true) + if(beam_generalized_gaussian == true) { if(beam_antialias_level > 1.5) { diff --git a/crt/shaders/crt-royale/src/tex2Dantialias.h b/crt/shaders/crt-royale/src/tex2Dantialias.h index 730ac26..af7dd59 100644 --- a/crt/shaders/crt-royale/src/tex2Dantialias.h +++ b/crt/shaders/crt-royale/src/tex2Dantialias.h @@ -500,7 +500,7 @@ vec4 tex2Daa_tiled_linearize(const sampler2D samp, const vec2 s) vec2 get_frame_sign(const float frame) { - if(aa_temporal) + if(aa_temporal == true) { // Mirror the sampling pattern for odd frames in a direction that // lets us keep the same subpixel sample weights: diff --git a/crt/shaders/crt-royale/user-settings.h b/crt/shaders/crt-royale/user-settings.h index 4014dae..fe97a96 100644 --- a/crt/shaders/crt-royale/user-settings.h +++ b/crt/shaders/crt-royale/user-settings.h @@ -172,7 +172,7 @@ // 4 scanlines, max_beam_sigma = 0.5723; distortions begin ~0.70; 134.7 FPS pure; 117.2 FPS generalized // 5 scanlines, max_beam_sigma = 0.7591; distortions begin ~0.89; 131.6 FPS pure; 112.1 FPS generalized // 6 scanlines, max_beam_sigma = 0.9483; distortions begin ~1.08; 127.9 FPS pure; 105.6 FPS generalized - const float beam_num_scanlines = 3.0; // range [2, 6] +// const float beam_num_scanlines = 3.0; // range [2, 6] // A generalized Gaussian beam varies shape with color too, now just width. // It's slower but more flexible (static option only for now). bool beam_generalized_gaussian = true;