mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-18 11:02:08 +00:00
Graphics Preferences: Anti-aliasing + FPS (#13538)
* Expose Antialiasing velues Expose Antialiasing multipliers. Default to 4 as current implementation but enables the user to disable it to improve performante or increase sampling to improve quality. * FXAA * Improve descriptions * Require restart when MSAA setting changes Detect changes to the OpenGL MSAA (multisample anti-aliasing) preference when opening Preferences and prompt the user to restart the application to apply the change. Adds a constant key for the MSAA setting, stores the previous value, checks for changes (similar to the existing FXAA handling), and shows a warning dialog explaining the restart will close the current project without saving. If the user accepts, recreate_GUI is invoked to apply the MSAA change immediately. * Revert "Require restart when MSAA setting changes" This reverts commit dde134d346c3849598c91d025d2faed1b51c8a22. * Menu and FPS options * Fix FPS limiter and remove VSYNC * Grouped FPS settings and mode up rigth fps counter --------- Co-authored-by: Noisyfox <timemanager.rick@gmail.com>
This commit is contained in:
50
resources/shaders/110/fxaa.fs
Normal file
50
resources/shaders/110/fxaa.fs
Normal file
@@ -0,0 +1,50 @@
|
||||
#version 110
|
||||
|
||||
uniform sampler2D uniform_texture;
|
||||
uniform vec2 inv_tex_size;
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 rgbNW = texture2D(uniform_texture, tex_coord + vec2(-1.0, -1.0) * inv_tex_size).rgb;
|
||||
vec3 rgbNE = texture2D(uniform_texture, tex_coord + vec2(1.0, -1.0) * inv_tex_size).rgb;
|
||||
vec3 rgbSW = texture2D(uniform_texture, tex_coord + vec2(-1.0, 1.0) * inv_tex_size).rgb;
|
||||
vec3 rgbSE = texture2D(uniform_texture, tex_coord + vec2(1.0, 1.0) * inv_tex_size).rgb;
|
||||
vec3 rgbM = texture2D(uniform_texture, tex_coord).rgb;
|
||||
|
||||
vec3 luma_coeff = vec3(0.299, 0.587, 0.114);
|
||||
float lumaNW = dot(rgbNW, luma_coeff);
|
||||
float lumaNE = dot(rgbNE, luma_coeff);
|
||||
float lumaSW = dot(rgbSW, luma_coeff);
|
||||
float lumaSE = dot(rgbSE, luma_coeff);
|
||||
float lumaM = dot(rgbM, luma_coeff);
|
||||
|
||||
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
||||
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
||||
|
||||
vec2 dir;
|
||||
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
||||
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
|
||||
|
||||
const float FXAA_REDUCE_MIN = 1.0 / 128.0;
|
||||
const float FXAA_REDUCE_MUL = 1.0 / 8.0;
|
||||
const float FXAA_SPAN_MAX = 8.0;
|
||||
|
||||
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
|
||||
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
|
||||
dir = min(vec2(FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX), dir * rcpDirMin)) * inv_tex_size;
|
||||
|
||||
vec3 rgbA = 0.5 * (
|
||||
texture2D(uniform_texture, tex_coord + dir * (1.0 / 3.0 - 0.5)).rgb +
|
||||
texture2D(uniform_texture, tex_coord + dir * (2.0 / 3.0 - 0.5)).rgb
|
||||
);
|
||||
|
||||
vec3 rgbB = rgbA * 0.5 + 0.25 * (
|
||||
texture2D(uniform_texture, tex_coord + dir * -0.5).rgb +
|
||||
texture2D(uniform_texture, tex_coord + dir * 0.5).rgb
|
||||
);
|
||||
|
||||
float lumaB = dot(rgbB, luma_coeff);
|
||||
gl_FragColor = (lumaB < lumaMin || lumaB > lumaMax) ? vec4(rgbA, 1.0) : vec4(rgbB, 1.0);
|
||||
}
|
||||
15
resources/shaders/110/fxaa.vs
Normal file
15
resources/shaders/110/fxaa.vs
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 110
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec2 v_tex_coord;
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coord = v_tex_coord;
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
52
resources/shaders/140/fxaa.fs
Normal file
52
resources/shaders/140/fxaa.fs
Normal file
@@ -0,0 +1,52 @@
|
||||
#version 140
|
||||
|
||||
uniform sampler2D uniform_texture;
|
||||
uniform vec2 inv_tex_size;
|
||||
|
||||
in vec2 tex_coord;
|
||||
|
||||
out vec4 out_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 rgbNW = texture(uniform_texture, tex_coord + vec2(-1.0, -1.0) * inv_tex_size).rgb;
|
||||
vec3 rgbNE = texture(uniform_texture, tex_coord + vec2(1.0, -1.0) * inv_tex_size).rgb;
|
||||
vec3 rgbSW = texture(uniform_texture, tex_coord + vec2(-1.0, 1.0) * inv_tex_size).rgb;
|
||||
vec3 rgbSE = texture(uniform_texture, tex_coord + vec2(1.0, 1.0) * inv_tex_size).rgb;
|
||||
vec3 rgbM = texture(uniform_texture, tex_coord).rgb;
|
||||
|
||||
vec3 luma_coeff = vec3(0.299, 0.587, 0.114);
|
||||
float lumaNW = dot(rgbNW, luma_coeff);
|
||||
float lumaNE = dot(rgbNE, luma_coeff);
|
||||
float lumaSW = dot(rgbSW, luma_coeff);
|
||||
float lumaSE = dot(rgbSE, luma_coeff);
|
||||
float lumaM = dot(rgbM, luma_coeff);
|
||||
|
||||
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
||||
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
||||
|
||||
vec2 dir;
|
||||
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
||||
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
|
||||
|
||||
const float FXAA_REDUCE_MIN = 1.0 / 128.0;
|
||||
const float FXAA_REDUCE_MUL = 1.0 / 8.0;
|
||||
const float FXAA_SPAN_MAX = 8.0;
|
||||
|
||||
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
|
||||
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
|
||||
dir = min(vec2(FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX), dir * rcpDirMin)) * inv_tex_size;
|
||||
|
||||
vec3 rgbA = 0.5 * (
|
||||
texture(uniform_texture, tex_coord + dir * (1.0 / 3.0 - 0.5)).rgb +
|
||||
texture(uniform_texture, tex_coord + dir * (2.0 / 3.0 - 0.5)).rgb
|
||||
);
|
||||
|
||||
vec3 rgbB = rgbA * 0.5 + 0.25 * (
|
||||
texture(uniform_texture, tex_coord + dir * -0.5).rgb +
|
||||
texture(uniform_texture, tex_coord + dir * 0.5).rgb
|
||||
);
|
||||
|
||||
float lumaB = dot(rgbB, luma_coeff);
|
||||
out_color = (lumaB < lumaMin || lumaB > lumaMax) ? vec4(rgbA, 1.0) : vec4(rgbB, 1.0);
|
||||
}
|
||||
15
resources/shaders/140/fxaa.vs
Normal file
15
resources/shaders/140/fxaa.vs
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 140
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
in vec3 v_position;
|
||||
in vec2 v_tex_coord;
|
||||
|
||||
out vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coord = v_tex_coord;
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user