diff --git a/app/qml/ApplicationSettings.qml b/app/qml/ApplicationSettings.qml index 620836e..a6e3e3e 100644 --- a/app/qml/ApplicationSettings.qml +++ b/app/qml/ApplicationSettings.qml @@ -58,6 +58,7 @@ Item{ property real bloom_strength: 0.65 property real bloom_quality: 0.5 + property real blur_quality: 0.5 property real chroma_color: 0.0 property real saturation_color: 0.0 @@ -168,7 +169,8 @@ Item{ fontIndexes: fontIndexes, frameReflections: _frameReflections, showMenubar: showMenubar, - bloom_quality: bloom_quality + bloom_quality: bloom_quality, + blur_quality: blur_quality } return stringify(settings); } @@ -243,6 +245,7 @@ Item{ showMenubar = settings.showMenubar !== undefined ? settings.showMenubar : showMenubar; bloom_quality = settings.bloom_quality !== undefined ? settings.bloom_quality : bloom_quality; + blur_quality = settings.blur_quality !== undefined ? settings.blur_quality : blur_quality; } function loadProfileString(profileString){ diff --git a/app/qml/PreprocessedTerminal.qml b/app/qml/PreprocessedTerminal.qml index 9a96ba5..773d210 100644 --- a/app/qml/PreprocessedTerminal.qml +++ b/app/qml/PreprocessedTerminal.qml @@ -28,7 +28,8 @@ Item{ property size virtualResolution: Qt.size(kterminal.width, kterminal.height) property alias mainTerminal: kterminal - property ShaderEffectSource mainSource: mBlur !== 0 ? blurredSourceLoader.item : kterminalSource + property ShaderEffectSource mainSource: kterminalSource + property ShaderEffectSource blurredSource: blurredSourceLoader.item property real scaleTexture: 1.0 property alias title: ksession.title @@ -41,9 +42,9 @@ Item{ //The blur effect has to take into account the framerate property real mBlur: appSettings.motion_blur - property real motionBlurCoefficient: (_maxBlurCoefficient * mBlur + _minBlurCoefficient * (1 - mBlur)) + property real motionBlurCoefficient: (_maxBlurCoefficient * Math.sqrt(mBlur) + _minBlurCoefficient * (1 - Math.sqrt(mBlur))) property real _minBlurCoefficient: 0.70 - property real _maxBlurCoefficient: 0.90 + property real _maxBlurCoefficient: 0.95 property size terminalSize: kterminal.terminalSize property size fontMetrics: kterminal.fontMetrics @@ -241,8 +242,8 @@ Item{ Loader{ id: blurredTerminalLoader - width: kterminalSource.textureSize.width - height: kterminalSource.textureSize.height + width: kterminal.width * scaleTexture * appSettings.blur_quality + height: kterminal.height * scaleTexture * appSettings.blur_quality active: mBlur !== 0 asynchronous: true @@ -268,13 +269,11 @@ Item{ "void main() {" + "vec2 coords = qt_TexCoord0;" + - "vec3 color = texture2D(txt_source, coords).rgb * 256.0;" + + "vec3 origColor = texture2D(txt_source, coords).rgb;" + + "vec3 blur_color = texture2D(blurredSource, coords).rgb * (1.0 - blurCoefficient);" + + "vec3 color = min(origColor + blur_color, max(origColor, blur_color));" + - "vec3 blur_color = texture2D(blurredSource, coords).rgb * 256.0;" + - "blur_color = blur_color - blur_color * blurCoefficient;" + - "color = step(vec3(1.0), color) * color + step(color, vec3(1.0)) * blur_color;" + - - "gl_FragColor = vec4(floor(color) / 256.0, 1.0);" + + "gl_FragColor = vec4(color, step(0.004, rgb2grey(color - origColor)));" + "}" onStatusChanged: if (log) console.log(log) //Print warning messages diff --git a/app/qml/SettingsPerformanceTab.qml b/app/qml/SettingsPerformanceTab.qml index 84b5748..5a58d42 100644 --- a/app/qml/SettingsPerformanceTab.qml +++ b/app/qml/SettingsPerformanceTab.qml @@ -83,6 +83,27 @@ Tab{ Text{text: Math.round(bloomSlider.value * 100) + "%"} } } + GroupBox{ + title: qsTr("Motion Blur") + Layout.fillWidth: true + anchors.left: parent.left + anchors.right: parent.right + GridLayout{ + id: blurQualityContainer + anchors.fill: parent + + Text{text: qsTr("Blur Quality")} + Slider{ + Layout.fillWidth: true + id: blurSlider + onValueChanged: appSettings.blur_quality = value; + value: appSettings.blur_quality + stepSize: 0.10 + Component.onCompleted: minimumValue = 0.3 //Without this value gets set to 0.5 + } + Text{text: Math.round(blurSlider.value * 100) + "%"} + } + } GroupBox{ title: qsTr("Frame") Layout.fillWidth: true diff --git a/app/qml/ShaderTerminal.qml b/app/qml/ShaderTerminal.qml index 08dda94..562b5b0 100644 --- a/app/qml/ShaderTerminal.qml +++ b/app/qml/ShaderTerminal.qml @@ -23,12 +23,15 @@ import QtGraphicalEffects 1.0 ShaderEffect { property ShaderEffectSource source + property ShaderEffectSource blurredSource property ShaderEffectSource bloomSource property color font_color: appSettings.font_color property color background_color: appSettings.background_color property real bloom_strength: appSettings.bloom_strength * 2.5 + property real motion_blur: appSettings.motion_blur + property real jitter: appSettings.jitter * 0.007 property real noise_strength: appSettings.noise_strength property size scaleNoiseSize: Qt.size((width) / (noiseTexture.width * appSettings.window_scaling * appSettings.fontScaling), @@ -156,6 +159,8 @@ ShaderEffect { (bloom_strength !== 0 ? " uniform highp sampler2D bloomSource; uniform lowp float bloom_strength;" : "") + + (motion_blur !== 0 ? " + uniform sampler2D blurredSource;" : "") + (noise_strength !== 0 ? " uniform highp float noise_strength;" : "") + (((noise_strength !== 0 || jitter !== 0 || rgb_shift) @@ -255,8 +260,14 @@ ShaderEffect { color += randomPass(coords) * glowing_line_strength;" : "") + - "vec3 txt_color = texture2D(source, txt_coords).rgb; - float greyscale_color = rgb2grey(txt_color) + color;" + + "vec3 txt_color = texture2D(source, txt_coords).rgb;" + + + (motion_blur !== 0 ? " + vec4 txt_blur = texture2D(blurredSource, txt_coords); + txt_color = txt_color + txt_blur.rgb * txt_blur.a;" + : "") + + + "float greyscale_color = rgb2grey(txt_color) + color;" + (chroma_color !== 0 ? (rgb_shift !== 0 ? " diff --git a/app/qml/TerminalContainer.qml b/app/qml/TerminalContainer.qml index 0117aa6..784a338 100644 --- a/app/qml/TerminalContainer.qml +++ b/app/qml/TerminalContainer.qml @@ -11,6 +11,7 @@ ShaderTerminal{ blending: false source: terminal.mainSource + blurredSource: terminal.blurredSource dispX: (12 / width) * appSettings.window_scaling dispY: (12 / height) * appSettings.window_scaling virtual_resolution: terminal.virtualResolution