From 8590410b30719bdb61223069aa15e12ae9f0a29f Mon Sep 17 00:00:00 2001 From: hunterk Date: Wed, 3 May 2017 16:34:58 -0500 Subject: [PATCH] try to get some more params working with royale --- crt/shaders/crt-royale/src/bind-shader-params.h | 6 +++--- crt/shaders/crt-royale/src/bloom-functions.h | 6 +++--- .../crt-royale/src/crt-royale-bloom-approx.slang | 8 ++++---- ...e-first-pass-linearize-crt-gamma-bob-fields.slang | 6 ++---- .../crt-royale-scanlines-vertical-interlacing.slang | 4 ++-- crt/shaders/crt-royale/user-settings.h | 12 ++++++------ 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/crt/shaders/crt-royale/src/bind-shader-params.h b/crt/shaders/crt-royale/src/bind-shader-params.h index 80adc7d..76145b0 100644 --- a/crt/shaders/crt-royale/src/bind-shader-params.h +++ b/crt/shaders/crt-royale/src/bind-shader-params.h @@ -39,7 +39,7 @@ const float gba_gamma = 3.5; // Irrelevant but necessary to define. // Bind option names to shader parameter uniforms or static constants. #ifdef PARAMETER_UNIFORM - uniform float crt_gamma; +/* uniform float crt_gamma; uniform float lcd_gamma; uniform float levels_contrast; uniform float halation_weight; @@ -97,7 +97,7 @@ const float gba_gamma = 3.5; // Irrelevant but necessary to define. uniform float border_darkness; uniform float border_compress; uniform float interlace_bff; - uniform float interlace_1080i; + uniform float interlace_1080i; */ #else // Use constants from user-settings.h, and limit ranges appropriately: const float crt_gamma = max(0.0, crt_gamma_static); @@ -126,7 +126,7 @@ const float gba_gamma = 3.5; // Irrelevant but necessary to define. const float mask_type = clamp(mask_type_static, 0.0, 2.0); const float mask_sample_mode_desired = clamp(mask_sample_mode_static, 0.0, 2.0); const float mask_specify_num_triads = clamp(mask_specify_num_triads_static, 0.0, 1.0); - const float mask_triad_size_desired = clamp(mask_triad_size_desired_static, 1.0, 18.0); + // const float mask_triad_size_desired = clamp(mask_triad_size_desired_static, 1.0, 18.0); const float mask_num_triads_desired = clamp(mask_num_triads_desired_static, 342.0, 1920.0); const float aa_subpixel_r_offset_x_runtime = clamp(aa_subpixel_r_offset_static.x, -0.5, 0.5); const float aa_subpixel_r_offset_y_runtime = clamp(aa_subpixel_r_offset_static.y, -0.5, 0.5); diff --git a/crt/shaders/crt-royale/src/bloom-functions.h b/crt/shaders/crt-royale/src/bloom-functions.h index 35909cd..7e00dee 100644 --- a/crt/shaders/crt-royale/src/bloom-functions.h +++ b/crt/shaders/crt-royale/src/bloom-functions.h @@ -246,9 +246,9 @@ float get_bloom_approx_sigma(const float output_size_x_runtime, const float mask_num_triads_static = max(min_allowed_viewport_triads.x, mask_num_triads_desired_static); const float mask_num_triads_from_size = - estimated_viewport_size_x/mask_triad_size_desired; + estimated_viewport_size_x/params.mask_triad_size_desired; const float mask_num_triads_runtime = max(min_allowed_viewport_triads.x, - mix(mask_num_triads_from_size, mask_num_triads_desired, + mix(mask_num_triads_from_size, params.mask_num_triads_desired, mask_specify_num_triads)); // Assume an extremely large viewport size for asymptotic results: const float max_viewport_size_x = 1080.0*1024.0*(4.0/3.0); @@ -303,7 +303,7 @@ float get_final_bloom_sigma(const float bloom_sigma_runtime) // Notes: Call this from the fragment shader, NOT the vertex shader, // so static sigmas can be constant-folded! const float bloom_sigma_optimistic = get_min_sigma_to_blur_triad( - mask_triad_size_desired_static, bloom_diff_thresh); + params.mask_triad_size_desired, bloom_diff_thresh); #ifdef RUNTIME_PHOSPHOR_BLOOM_SIGMA return bloom_sigma_runtime; #else 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 b99bc05..e07e58a 100755 --- a/crt/shaders/crt-royale/src/crt-royale-bloom-approx.slang +++ b/crt/shaders/crt-royale/src/crt-royale-bloom-approx.slang @@ -269,9 +269,9 @@ void main() if(beam_misconvergence == true) { - const vec2 convergence_offsets_r = get_convergence_offsets_r_vector(); - const vec2 convergence_offsets_g = get_convergence_offsets_g_vector(); - const vec2 convergence_offsets_b = get_convergence_offsets_b_vector(); + const vec2 convergence_offsets_r = vec2(params.convergence_offset_x_r, params.convergence_offset_y_r);//get_convergence_offsets_r_vector(); + const vec2 convergence_offsets_g = vec2(params.convergence_offset_x_g, params.convergence_offset_y_g);//get_convergence_offsets_g_vector(); + const vec2 convergence_offsets_b = vec2(params.convergence_offset_x_b, params.convergence_offset_y_b);//get_convergence_offsets_b_vector(); tex_uv_r = tex_uv - vec2(params.convergence_offset_x_r, params.convergence_offset_y_r) * uv_scanline_step; tex_uv_g = tex_uv - vec2(params.convergence_offset_x_g, params.convergence_offset_y_g) * uv_scanline_step; tex_uv_b = tex_uv - vec2(params.convergence_offset_x_b, params.convergence_offset_y_b) * uv_scanline_step; @@ -350,5 +350,5 @@ void main() color = vec3(color_r.r, color_g.g, color_b.b); } // Encode and output the blurred image: - FragColor = vec4(color, 1.0); + FragColor = vec4(color, 1.0);//vec4(texture(ORIG_LINEARIZED, tex_uv));// } 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 6cf2c40..fd67019 100755 --- 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 @@ -12,7 +12,7 @@ layout(std140, set = 0, binding = 0) uniform UBO float interlace_bff; } params; -#pragma parameter interlace_bff "interlace_bff" 0.0 0.0 1.0 1.0 +#pragma parameter interlace_bff "interlace_bff" 1.0 0.0 1.0 1.0 ///////////////////////////// GPL LICENSE NOTICE ///////////////////////////// @@ -94,9 +94,7 @@ if(interlace_detect == true) Source, tex_uv + v_step).rgb; const vec3 interpolated_line = 0.5 * (last_line + next_line); // If we're interlacing, determine which field curr_line is in: - float interlace_check = 0.0; - if (interlaced == true) interlace_check = 1.0; - const float modulus = interlace_check + 1.0; + const float modulus = float(interlaced) + 1.0; const float field_offset = mod(registers.FrameCount + float(params.interlace_bff), modulus); const float curr_line_texel = tex_uv.y * registers.SourceSize.y; 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 bf8f6cd..cfc0e64 100755 --- a/crt/shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.slang +++ b/crt/shaders/crt-royale/src/crt-royale-scanlines-vertical-interlacing.slang @@ -31,7 +31,7 @@ layout(push_constant) uniform Push ////////////////////////////////// INCLUDES ////////////////////////////////// -#include "../user-settings.h" +//#include "../user-settings.h" #include "derived-settings-and-constants.h" #include "bind-shader-params.h" #include "scanline-functions.h" @@ -164,7 +164,7 @@ void main() if(beam_misconvergence == true) { const vec3 convergence_offsets_vert_rgb = - get_convergence_offsets_y_vector(); + vec3(params.convergence_offset_y_r, params.convergence_offset_y_g, params.convergence_offset_y_b);//get_convergence_offsets_y_vector(); dist2 = vec3(dist) - convergence_offsets_vert_rgb; } // Calculate {sigma, shape}_range outside of scanline_contrib so it's only diff --git a/crt/shaders/crt-royale/user-settings.h b/crt/shaders/crt-royale/user-settings.h index fe97a96..cc375df 100644 --- a/crt/shaders/crt-royale/user-settings.h +++ b/crt/shaders/crt-royale/user-settings.h @@ -74,7 +74,7 @@ // Enable runtime shader parameters in the Retroarch (etc.) GUI? They override // many of the options in this file and allow real-time tuning, but many of // them are slower. Disabling them and using this text file will boost FPS. -//#define RUNTIME_SHADER_PARAMS_ENABLE +#define RUNTIME_SHADER_PARAMS_ENABLE // Specify the phosphor bloom sigma at runtime? This option is 10% slower, but // it's the only way to do a wide-enough full bloom with a runtime dot pitch. #define RUNTIME_PHOSPHOR_BLOOM_SIGMA @@ -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; @@ -218,9 +218,9 @@ bool beam_misconvergence = true; // Convergence offsets in x/y directions for R/G/B scanline beams in units // of scanlines. Positive offsets go right/down; ranges [-2, 2] - const vec2 convergence_offsets_r_static = vec2(0.1, 0.2); - const vec2 convergence_offsets_g_static = vec2(0.3, 0.4); - const vec2 convergence_offsets_b_static = vec2(0.5, 0.6); + const vec2 convergence_offsets_r_static = vec2(0.0, 0.0); + const vec2 convergence_offsets_g_static = vec2(0.0, 0.0); + const vec2 convergence_offsets_b_static = vec2(0.0, 0.0); // Detect interlacing (static option only for now)? bool interlace_detect = true; // Assume 1080-line sources are interlaced? @@ -280,7 +280,7 @@ // To increase the size limit, double the viewport-relative scales for the // two MASK_RESIZE passes in crt-royale.cgp and user-cgp-contants.h. // range [1, mask_texture_small_size/mask_triads_per_tile] - const float mask_triad_size_desired_static = 24.0 / 8.0; +// const float mask_triad_size_desired_static = 24.0 / 8.0; // If mask_specify_num_triads is 1.0/true, we'll go by this instead (the // final size will be rounded and constrained as above); default 480.0 const float mask_num_triads_desired_static = 480.0;