1
0
mirror of https://github.com/Swordfish90/cool-retro-term.git synced 2025-02-27 15:29:03 +00:00

Added a really cool motion blur to the screen!

This commit is contained in:
Filippo Scognamiglio 2014-03-22 11:11:27 +01:00
parent 5aa1da233a
commit 03a72e39b9
5 changed files with 98 additions and 35 deletions

@ -28,6 +28,7 @@ RowLayout {
property double _value: 0.0 property double _value: 0.0
property double min_value: 0.0 property double min_value: 0.0
property double max_value: 1.0 property double max_value: 1.0
property double stepSize: 0.01
id: setting_component id: setting_component
anchors.left: parent.left anchors.left: parent.left
@ -43,7 +44,7 @@ RowLayout {
} }
Slider{ Slider{
id: slider id: slider
stepSize: 0.01 stepSize: parent.stepSize
minimumValue: min_value minimumValue: min_value
maximumValue: max_value maximumValue: max_value
onValueChanged: setting_component._value = slider.value; onValueChanged: setting_component._value = slider.value;
@ -55,6 +56,6 @@ RowLayout {
} }
Text{ Text{
id: textfield id: textfield
text: Math.round(((_value - min_value) / (max_value - min_value)) * 100) + "%" text: Math.round(((value - min_value) / (max_value - min_value)) * 100) + "%"
} }
} }

@ -138,6 +138,11 @@ ApplicationWindow {
checked: shadersettings.scanlines checked: shadersettings.scanlines
onCheckedChanged: shadersettings.scanlines = checked; onCheckedChanged: shadersettings.scanlines = checked;
} }
SettingComponent{
name: "Motion Blur"
onValueChanged: shadersettings.motion_blur = value
_value: shadersettings.motion_blur
}
SettingComponent{ SettingComponent{
name: "Noise" name: "Noise"
onValueChanged: shadersettings.noise_strength = value onValueChanged: shadersettings.noise_strength = value

@ -32,8 +32,9 @@ Item{
property real noise_strength: 0.1 property real noise_strength: 0.1
property real screen_distortion: 0.15 property real screen_distortion: 0.15
property real glowing_line_strength: 0.4 property real glowing_line_strength: 0.4
property real motion_blur: 0.65
property bool scanlines: true property bool scanlines: false
property string frame_source: frames_list.get(frames_index).source property string frame_source: frames_list.get(frames_index).source
property int frames_index: 2 property int frames_index: 2
@ -112,6 +113,8 @@ Item{
glowing_line_strength = settings.glowing_line_strength ? settings.glowing_line_strength : glowing_line_strength; glowing_line_strength = settings.glowing_line_strength ? settings.glowing_line_strength : glowing_line_strength;
scanlines = settings.scanlines ? settings.scanlines : scanlines; scanlines = settings.scanlines ? settings.scanlines : scanlines;
motion_blur = settings.motion_blur ? settings.motion_blur : motion_blur
frames_index = settings.frames_index ? settings.frames_index : frames_index; frames_index = settings.frames_index ? settings.frames_index : frames_index;
font_index = settings.font_index ? settings.font_index : font_index; font_index = settings.font_index ? settings.font_index : font_index;
@ -130,7 +133,8 @@ Item{
scanlines: scanlines, scanlines: scanlines,
frames_index: frames_index, frames_index: frames_index,
font_index: font_index, font_index: font_index,
font_scaling: font_scaling font_scaling: font_scaling,
motion_blur: motion_blur
} }
console.log(JSON.stringify(settings)); console.log(JSON.stringify(settings));

@ -2,11 +2,20 @@ import QtQuick 2.0
import org.kde.konsole 0.1 import org.kde.konsole 0.1
KTerminal { Item{
id: terminalContainer
property real blur: shadersettings.motion_blur
property real motionBlurCoefficient: (_minBlurCoefficient)*blur + (_maxBlurCoefficient)*(1.0-blur)
property real _minBlurCoefficient: 0.015
property real _maxBlurCoefficient: 0.10
KTerminal {
id: kterminal
font.pointSize: shadersettings.fontSize font.pointSize: shadersettings.fontSize
font.family: shadersettings.font.name font.family: shadersettings.font.name
width: parent.width
height: parent.height
colorScheme: "WhiteOnBlack" colorScheme: "MyWhiteOnBlack"
session: KSession { session: KSession {
id: ksession id: ksession
@ -20,8 +29,44 @@ KTerminal {
Component.onCompleted: { Component.onCompleted: {
font.pointSize = shadersettings.fontSize; font.pointSize = shadersettings.fontSize;
font.family = shadersettings.font.name; font.family = shadersettings.font.name;
console.log(shadersettings.font.name); forceActiveFocus();
}
} }
Component.onDestruction: console.log("Destroy") Loader{
anchors.fill: parent
active: parent.blur !== 0
sourceComponent: Item{
ShaderEffectSource{
id: source
sourceItem: kterminal
hideSource: true
}
ShaderEffectSource{
id: blurredSource
sourceItem: blurredterminal
recursive: true
live: true
}
ShaderEffect {
id: blurredterminal
anchors.fill: parent
property variant source: source
property variant blurredSource: blurredSource
z: 2
fragmentShader:
"uniform lowp float qt_Opacity;" +
"uniform lowp sampler2D source;" +
"uniform lowp sampler2D blurredSource;" +
"varying highp vec2 qt_TexCoord0;" +
"void main() {" +
" float sourceColor = texture2D(source, qt_TexCoord0).r * 512.0;" +
" float blurredSourceColor = texture2D(blurredSource, qt_TexCoord0).r * 512.0;" +
" gl_FragColor = vec4(vec3(floor(mix(blurredSourceColor, sourceColor, " + motionBlurCoefficient + "))) / 512.0, 1.0);" +
"}"
}
}
}
} }

@ -98,10 +98,18 @@ ApplicationWindow{
Loader{ Loader{
id: terminal id: terminal
width: parent.width width: parent.width
height: parent.height height: parent.height
} }
MouseArea{
acceptedButtons: Qt.NoButton
anchors.fill: parent
onWheel:
wheel.angleDelta.y > 0 ? terminal.item.scrollUp() : terminal.item.scrollDown()
}
RadialGradient{ RadialGradient{
id: ambientreflection id: ambientreflection
z: 2.0 z: 2.0