mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-02-22 12:58:39 +00:00
Improved scanlines, restructurizations of the effects and optimizations.
This commit is contained in:
parent
7850df26a1
commit
947b355c29
@ -24,19 +24,13 @@ import QtGraphicalEffects 1.0
|
|||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
property color font_color: shadersettings.font_color
|
property color font_color: shadersettings.font_color
|
||||||
property color background_color: shadersettings.background_color
|
property color background_color: shadersettings.background_color
|
||||||
property variant source: theSource
|
property variant source: terminal.theSource
|
||||||
property variant bloomSource: bloomSource
|
property variant bloomSource: terminal.bloomSource
|
||||||
|
property variant scanlineSource: terminal.scanlineSource
|
||||||
property size txt_Size: Qt.size(frame.sourceRect.width, frame.sourceRect.height)
|
property size txt_Size: Qt.size(frame.sourceRect.width, frame.sourceRect.height)
|
||||||
property real bloom: shadersettings.bloom_strength
|
property real bloom: shadersettings.bloom_strength
|
||||||
|
|
||||||
property int rasterization: shadersettings.rasterization
|
property int rasterization: shadersettings.rasterization
|
||||||
property real _verticalResDensity: shadersettings.font.virtualResolution.height + shadersettings.font.lineSpacing
|
|
||||||
property real _horizontalResDensity: shadersettings.font.virtualResolution.width
|
|
||||||
property real _lines: frame.sourceRect.height / terminal.paintedFontSize.height
|
|
||||||
property real _columns: frame.sourceRect.width / terminal.paintedFontSize.width
|
|
||||||
property size virtual_resolution: Qt.size(_columns * _horizontalResDensity, _lines * _verticalResDensity)
|
|
||||||
property real scanlineHeight: frame.sourceRect.height / virtual_resolution.height
|
|
||||||
property real scanlineWidth: frame.sourceRect.width / virtual_resolution.width
|
|
||||||
|
|
||||||
property real noise_strength: shadersettings.noise_strength
|
property real noise_strength: shadersettings.noise_strength
|
||||||
property real screen_distorsion: shadersettings.screen_distortion
|
property real screen_distorsion: shadersettings.screen_distortion
|
||||||
@ -54,9 +48,6 @@ ShaderEffect {
|
|||||||
|
|
||||||
property real brightness: shadersettings.brightness * 1.5 + 0.5
|
property real brightness: shadersettings.brightness * 1.5 + 0.5
|
||||||
|
|
||||||
property real deltay: scanlineHeight / (frame.sourceRect.height)
|
|
||||||
property real deltax: scanlineWidth / (frame.sourceRect.width)
|
|
||||||
|
|
||||||
property real time: timetimer.time
|
property real time: timetimer.time
|
||||||
property variant randomFunctionSource: randfuncsource
|
property variant randomFunctionSource: randfuncsource
|
||||||
|
|
||||||
@ -64,23 +55,6 @@ ShaderEffect {
|
|||||||
return num.toFixed(8);
|
return num.toFixed(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Blurred texture used for bloom
|
|
||||||
Loader{
|
|
||||||
anchors.fill: parent
|
|
||||||
active: bloom !== 0
|
|
||||||
FastBlur{
|
|
||||||
radius: 32
|
|
||||||
anchors.fill: parent
|
|
||||||
source: theSource
|
|
||||||
transparentBorder: true
|
|
||||||
ShaderEffectSource{
|
|
||||||
id: bloomSource
|
|
||||||
sourceItem: parent
|
|
||||||
hideSource: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vertexShader: "
|
vertexShader: "
|
||||||
uniform highp mat4 qt_Matrix;
|
uniform highp mat4 qt_Matrix;
|
||||||
uniform highp float time;
|
uniform highp float time;
|
||||||
@ -122,9 +96,10 @@ ShaderEffect {
|
|||||||
varying highp vec2 qt_TexCoord0;
|
varying highp vec2 qt_TexCoord0;
|
||||||
|
|
||||||
uniform highp vec4 font_color;
|
uniform highp vec4 font_color;
|
||||||
uniform highp vec4 background_color;
|
uniform highp vec4 background_color;" +
|
||||||
|
|
||||||
uniform highp vec2 virtual_resolution;" +
|
(rasterization != shadersettings.no_rasterization ? "
|
||||||
|
uniform highp sampler2D scanlineSource;" : "") +
|
||||||
|
|
||||||
(bloom !== 0 ? "
|
(bloom !== 0 ? "
|
||||||
uniform highp sampler2D bloomSource;" : "") +
|
uniform highp sampler2D bloomSource;" : "") +
|
||||||
@ -139,14 +114,6 @@ ShaderEffect {
|
|||||||
(horizontal_sincronization !== 0 ? "
|
(horizontal_sincronization !== 0 ? "
|
||||||
varying lowp float horizontal_distortion;" : "") +
|
varying lowp float horizontal_distortion;" : "") +
|
||||||
|
|
||||||
(rasterization !== shadersettings.no_rasterization ? "
|
|
||||||
float getScanlineIntensity(vec2 coord){
|
|
||||||
float result = abs(sin(coord.y * virtual_resolution.y * "+str(Math.PI)+" ));" +
|
|
||||||
(rasterization === shadersettings.pixel_rasterization ? "
|
|
||||||
result *= abs(sin(coord.x * virtual_resolution.x * "+str(Math.PI)+"));" : "") +
|
|
||||||
"return result;
|
|
||||||
}" : "") +
|
|
||||||
|
|
||||||
"
|
"
|
||||||
highp float rand(vec2 co)
|
highp float rand(vec2 co)
|
||||||
{
|
{
|
||||||
@ -159,7 +126,7 @@ ShaderEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float stepNoise(vec2 p){
|
float stepNoise(vec2 p){
|
||||||
vec2 newP = p * virtual_resolution;
|
vec2 newP = p * txt_Size * 0.5;
|
||||||
return rand(floor(newP) + fract(time / 100.0));
|
return rand(floor(newP) + fract(time / 100.0));
|
||||||
}" +
|
}" +
|
||||||
|
|
||||||
@ -194,23 +161,13 @@ ShaderEffect {
|
|||||||
noise += horizontal_distortion;" : "")
|
noise += horizontal_distortion;" : "")
|
||||||
: "") +
|
: "") +
|
||||||
|
|
||||||
(rasterization !== shadersettings.no_rasterization ? "
|
"float color = texture2D(source, coords).r;" +
|
||||||
vec2 txt_coords = coords;
|
|
||||||
txt_coords.y = floor(coords.y * virtual_resolution.y) / virtual_resolution.y;" +
|
|
||||||
(rasterization === shadersettings.pixel_rasterization ?
|
|
||||||
"txt_coords.x = floor(coords.x * virtual_resolution.x) / virtual_resolution.x;" : "")
|
|
||||||
: " vec2 txt_coords = coords;") +
|
|
||||||
|
|
||||||
"float color = texture2D(source, txt_coords + vec2("+str(deltax * 0.5)+", "+str(deltay * 0.5)+")).r;" +
|
|
||||||
|
|
||||||
(noise_strength !== 0 ? "
|
(noise_strength !== 0 ? "
|
||||||
color += stepNoise(coords) * noise * (1.0 - distance * distance * 2.0);" : "") +
|
color += stepNoise(coords) * noise * (1.0 - distance * distance * 2.0);" : "") +
|
||||||
|
|
||||||
(rasterization !== shadersettings.no_rasterization ? "
|
|
||||||
color = color * getScanlineIntensity(coords);" : "") +
|
|
||||||
|
|
||||||
(glowing_line_strength !== 0 ? "
|
(glowing_line_strength !== 0 ? "
|
||||||
color += randomPass(txt_coords) * glowing_line_strength;" : "") +
|
color += randomPass(coords) * glowing_line_strength;" : "") +
|
||||||
|
|
||||||
(bloom !== 0 ? "
|
(bloom !== 0 ? "
|
||||||
color += texture2D(bloomSource, coords).r *" + str(2.5 * bloom) + ";" : "") +
|
color += texture2D(bloomSource, coords).r *" + str(2.5 * bloom) + ";" : "") +
|
||||||
@ -218,6 +175,9 @@ ShaderEffect {
|
|||||||
"vec3 finalColor = mix(background_color, font_color, color).rgb;" +
|
"vec3 finalColor = mix(background_color, font_color, color).rgb;" +
|
||||||
"finalColor = mix(finalColor * 1.1, vec3(0.0), 1.2 * distance * distance);" +
|
"finalColor = mix(finalColor * 1.1, vec3(0.0), 1.2 * distance * distance);" +
|
||||||
|
|
||||||
|
(rasterization != shadersettings.no_rasterization ? "
|
||||||
|
finalColor *= texture2D(scanlineSource, coords).r;" : "") +
|
||||||
|
|
||||||
(brightness_flickering !== 0 ? "
|
(brightness_flickering !== 0 ? "
|
||||||
finalColor *= brightness;" : "") +
|
finalColor *= brightness;" : "") +
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ Item{
|
|||||||
var f = fontlist.get(font_index);
|
var f = fontlist.get(font_index);
|
||||||
var metrics = f.metrics.get(font_scaling_index);
|
var metrics = f.metrics.get(font_scaling_index);
|
||||||
currentfont.source = f.source;
|
currentfont.source = f.source;
|
||||||
currentfont.pixelSize = metrics.px;
|
currentfont.pixelSize = metrics.pixelSize;
|
||||||
currentfont.lineSpacing = f.lineSpacing;
|
currentfont.lineSpacing = f.lineSpacing;
|
||||||
currentfont.virtualResolution = Qt.size(metrics.virtualWidth,
|
currentfont.virtualResolution = Qt.size(metrics.virtualWidth,
|
||||||
metrics.virtualHeight);
|
metrics.virtualHeight);
|
||||||
@ -121,94 +121,94 @@ Item{
|
|||||||
id: fontlist
|
id: fontlist
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "Terminus (Modern)"
|
text: "Terminus (Modern)"
|
||||||
source: "fonts/modern-terminus/TerminusTTF-4.38.2.ttf"
|
source: "fonts/modern-terminus/TerminusTTF-Bold-4.38.2.ttf"
|
||||||
lineSpacing: 1
|
lineSpacing: 2
|
||||||
metrics: [
|
metrics: [
|
||||||
ListElement{px: 18; virtualWidth: 3; virtualHeight: 6},
|
ListElement{pixelSize: 18; virtualWidth: 0; virtualHeight: 6},
|
||||||
ListElement{px: 27; virtualWidth: 5; virtualHeight: 8},
|
ListElement{pixelSize: 24; virtualWidth: 0; virtualHeight: 8},
|
||||||
ListElement{px: 36; virtualWidth: 6; virtualHeight: 11},
|
ListElement{pixelSize: 35; virtualWidth: 5; virtualHeight: 12},
|
||||||
ListElement{px: 44; virtualWidth: 7; virtualHeight: 11},
|
ListElement{pixelSize: 47; virtualWidth: 6; virtualHeight: 11},
|
||||||
ListElement{px: 54; virtualWidth: 7; virtualHeight: 11},
|
ListElement{pixelSize: 54; virtualWidth: 7; virtualHeight: 11},
|
||||||
ListElement{px: 62; virtualWidth: 8; virtualHeight: 13},
|
ListElement{pixelSize: 64; virtualWidth: 8; virtualHeight: 11},
|
||||||
ListElement{px: 71; virtualWidth: 7; virtualHeight: 13}]
|
ListElement{pixelSize: 75; virtualWidth: 8; virtualHeight: 11}]
|
||||||
}
|
}
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "Commodore PET (1977)"
|
text: "Commodore PET (1977)"
|
||||||
source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf"
|
source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf"
|
||||||
lineSpacing: 2
|
lineSpacing: 2
|
||||||
metrics: [
|
metrics: [
|
||||||
ListElement{px: 16; virtualWidth: 8; virtualHeight: 6},
|
ListElement{pixelSize: 11; virtualWidth: 0; virtualHeight: 0},
|
||||||
ListElement{px: 20; virtualWidth: 7; virtualHeight: 6},
|
ListElement{pixelSize: 17; virtualWidth: 0; virtualHeight: 6},
|
||||||
ListElement{px: 27; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 24; virtualWidth: 8; virtualHeight: 8},
|
||||||
ListElement{px: 34; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 32; virtualWidth: 8; virtualHeight: 8},
|
||||||
ListElement{px: 40; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 40; virtualWidth: 8; virtualHeight: 8},
|
||||||
ListElement{px: 44; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 48; virtualWidth: 8; virtualHeight: 8},
|
||||||
ListElement{px: 50; virtualWidth: 8; virtualHeight: 8}]
|
ListElement{pixelSize: 56; virtualWidth: 8; virtualHeight: 8}]
|
||||||
}
|
}
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "Apple ][ (1977)"
|
text: "Apple ][ (1977)"
|
||||||
source: "fonts/1977-apple2/PrintChar21.ttf"
|
source: "fonts/1977-apple2/PrintChar21.ttf"
|
||||||
lineSpacing: 2
|
lineSpacing: 2
|
||||||
metrics: [
|
metrics: [
|
||||||
ListElement{px: 15; virtualWidth: 6; virtualHeight: 5},
|
ListElement{pixelSize: 11; virtualWidth: 0; virtualHeight: 0},
|
||||||
ListElement{px: 21; virtualWidth: 6; virtualHeight: 7},
|
ListElement{pixelSize: 17; virtualWidth: 0; virtualHeight: 6},
|
||||||
ListElement{px: 27; virtualWidth: 7; virtualHeight: 8},
|
ListElement{pixelSize: 24; virtualWidth: 7; virtualHeight: 8},
|
||||||
ListElement{px: 34; virtualWidth: 7; virtualHeight: 8},
|
ListElement{pixelSize: 32; virtualWidth: 7; virtualHeight: 8},
|
||||||
ListElement{px: 40; virtualWidth: 7; virtualHeight: 8},
|
ListElement{pixelSize: 40; virtualWidth: 7; virtualHeight: 8},
|
||||||
ListElement{px: 47; virtualWidth: 7; virtualHeight: 8},
|
ListElement{pixelSize: 48; virtualWidth: 7; virtualHeight: 8},
|
||||||
ListElement{px: 54; virtualWidth: 7; virtualHeight: 8}]
|
ListElement{pixelSize: 56; virtualWidth: 7; virtualHeight: 8}]
|
||||||
}
|
}
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "Atari 400-800 (1979)"
|
text: "Atari 400-800 (1979)"
|
||||||
source: "fonts/1979-atari-400-800/ATARI400800_original.TTF"
|
source: "fonts/1979-atari-400-800/ATARI400800_original.TTF"
|
||||||
lineSpacing: 3
|
lineSpacing: 3
|
||||||
metrics: [
|
metrics: [
|
||||||
ListElement{px: 16; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 11; virtualWidth: 0; virtualHeight: 0},
|
||||||
ListElement{px: 20; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 17; virtualWidth: 0; virtualHeight: 6},
|
||||||
ListElement{px: 25; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 24; virtualWidth: 8; virtualHeight: 8},
|
||||||
ListElement{px: 31; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 32; virtualWidth: 8; virtualHeight: 8},
|
||||||
ListElement{px: 38; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 40; virtualWidth: 8; virtualHeight: 8},
|
||||||
ListElement{px: 47; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 48; virtualWidth: 8; virtualHeight: 8},
|
||||||
ListElement{px: 54; virtualWidth: 8; virtualHeight: 8}]
|
ListElement{pixelSize: 56; virtualWidth: 8; virtualHeight: 8}]
|
||||||
}
|
}
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "Commodore 64 (1982)"
|
text: "Commodore 64 (1982)"
|
||||||
source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf"
|
source: "fonts/1982-commodore64/C64_User_Mono_v1.0-STYLE.ttf"
|
||||||
lineSpacing: 3
|
lineSpacing: 3
|
||||||
metrics: [
|
metrics: [
|
||||||
ListElement{px: 16; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 11; virtualWidth: 0; virtualHeight: 0},
|
||||||
ListElement{px: 20; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 17; virtualWidth: 0; virtualHeight: 6},
|
||||||
ListElement{px: 25; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 24; virtualWidth: 8; virtualHeight: 8},
|
||||||
ListElement{px: 31; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 32; virtualWidth: 8; virtualHeight: 8},
|
||||||
ListElement{px: 38; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 40; virtualWidth: 8; virtualHeight: 8},
|
||||||
ListElement{px: 47; virtualWidth: 8; virtualHeight: 8},
|
ListElement{pixelSize: 48; virtualWidth: 8; virtualHeight: 8},
|
||||||
ListElement{px: 54; virtualWidth: 8; virtualHeight: 8}]
|
ListElement{pixelSize: 56; virtualWidth: 8; virtualHeight: 8}]
|
||||||
}
|
}
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "Atari ST (1985)"
|
text: "Atari ST (1985)"
|
||||||
source: "fonts/1985-atari-st/AtariST8x16SystemFont.ttf"
|
source: "fonts/1985-atari-st/AtariST8x16SystemFont.ttf"
|
||||||
lineSpacing: 4
|
lineSpacing: 2
|
||||||
metrics: [
|
metrics: [
|
||||||
ListElement{px: 16; virtualWidth: 3; virtualHeight: 5},
|
ListElement{pixelSize: 16; virtualWidth: 0; virtualHeight: 0},
|
||||||
ListElement{px: 23; virtualWidth: 4; virtualHeight: 7},
|
ListElement{pixelSize: 23; virtualWidth: 0; virtualHeight: 7},
|
||||||
ListElement{px: 30; virtualWidth: 4; virtualHeight: 10},
|
ListElement{pixelSize: 32; virtualWidth: 4; virtualHeight: 8},
|
||||||
ListElement{px: 38; virtualWidth: 6; virtualHeight: 10},
|
ListElement{pixelSize: 40; virtualWidth: 4; virtualHeight: 8},
|
||||||
ListElement{px: 44; virtualWidth: 7; virtualHeight: 14},
|
ListElement{pixelSize: 48; virtualWidth: 4; virtualHeight: 8},
|
||||||
ListElement{px: 53; virtualWidth: 7; virtualHeight: 14},
|
ListElement{pixelSize: 56; virtualWidth: 4; virtualHeight: 8},
|
||||||
ListElement{px: 58; virtualWidth: 7; virtualHeight: 14}]
|
ListElement{pixelSize: 64; virtualWidth: 8; virtualHeight: 16}]
|
||||||
}
|
}
|
||||||
ListElement{
|
ListElement{
|
||||||
text: "IBM DOS (1985)"
|
text: "IBM DOS (1985)"
|
||||||
source: "fonts/1985-ibm-pc-vga/Perfect DOS VGA 437.ttf"
|
source: "fonts/1985-ibm-pc-vga/Perfect DOS VGA 437.ttf"
|
||||||
lineSpacing: 2
|
lineSpacing: 2
|
||||||
metrics: [
|
metrics: [
|
||||||
ListElement{px: 18; virtualWidth: 5; virtualHeight: 7},
|
ListElement{pixelSize: 18; virtualWidth: 0; virtualHeight: 0},
|
||||||
ListElement{px: 25; virtualWidth: 5; virtualHeight: 9},
|
ListElement{pixelSize: 25; virtualWidth: 0; virtualHeight: 0},
|
||||||
ListElement{px: 36; virtualWidth: 6; virtualHeight: 12},
|
ListElement{pixelSize: 32; virtualWidth: 6; virtualHeight: 8},
|
||||||
ListElement{px: 45; virtualWidth: 7; virtualHeight: 15},
|
ListElement{pixelSize: 36; virtualWidth: 6; virtualHeight: 12},
|
||||||
ListElement{px: 54; virtualWidth: 8; virtualHeight: 15},
|
ListElement{pixelSize: 48; virtualWidth: 9; virtualHeight: 16},
|
||||||
ListElement{px: 62; virtualWidth: 8; virtualHeight: 15},
|
ListElement{pixelSize: 56; virtualWidth: 9; virtualHeight: 16},
|
||||||
ListElement{px: 74; virtualWidth: 9; virtualHeight: 16}]
|
ListElement{pixelSize: 64; virtualWidth: 9; virtualHeight: 16}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
128
app/Terminal.qml
128
app/Terminal.qml
@ -26,6 +26,10 @@ import org.kde.konsole 0.1
|
|||||||
|
|
||||||
Item{
|
Item{
|
||||||
id: terminalContainer
|
id: terminalContainer
|
||||||
|
property variant theSource: finalSource
|
||||||
|
property variant bloomSource: bloomSourceLoader.item
|
||||||
|
property variant scanlineSource: scanlineSourceLoader.item
|
||||||
|
|
||||||
//The blur effect has to take into account the framerate
|
//The blur effect has to take into account the framerate
|
||||||
property real fpsAttenuation: 60 / shadersettings.fps
|
property real fpsAttenuation: 60 / shadersettings.fps
|
||||||
property real mBlur: shadersettings.motion_blur
|
property real mBlur: shadersettings.motion_blur
|
||||||
@ -33,14 +37,23 @@ Item{
|
|||||||
property real _minBlurCoefficient: 0.75
|
property real _minBlurCoefficient: 0.75
|
||||||
property real _maxBlurCoefficient: 0.95
|
property real _maxBlurCoefficient: 0.95
|
||||||
|
|
||||||
|
property real scanlineWidth: 1
|
||||||
|
property real scanlineHeight: 1
|
||||||
|
property size virtual_resolution: Qt.size(width / scanlineWidth, height / scanlineHeight)
|
||||||
|
property real deltay: 0.5 / virtual_resolution.height
|
||||||
|
property real deltax: 0.5 / virtual_resolution.width
|
||||||
|
|
||||||
property real mBloom: shadersettings.bloom_strength
|
property real mBloom: shadersettings.bloom_strength
|
||||||
|
property int mScanlines: shadersettings.rasterization
|
||||||
|
onMScanlinesChanged: restartBlurredSource()
|
||||||
|
|
||||||
property size terminalSize
|
property size terminalSize
|
||||||
property size _paintedFontSize
|
property size paintedTextSize
|
||||||
property size paintedFontSize: _paintedFontSize ? _paintedFontSize : 0
|
|
||||||
|
onPaintedTextSizeChanged: console.log(paintedTextSize)
|
||||||
|
|
||||||
//Force reload of the blursource when settings change
|
//Force reload of the blursource when settings change
|
||||||
onMBloomChanged: restartBlurredSource()
|
onMBlurChanged: restartBlurredSource()
|
||||||
|
|
||||||
function restartBlurredSource(){
|
function restartBlurredSource(){
|
||||||
if(!blurredSource) return;
|
if(!blurredSource) return;
|
||||||
@ -73,7 +86,6 @@ Item{
|
|||||||
colorScheme: "MyWhiteOnBlack"
|
colorScheme: "MyWhiteOnBlack"
|
||||||
|
|
||||||
onTerminalSizeChanged: terminalContainer.terminalSize = ktermitem.terminalSize
|
onTerminalSizeChanged: terminalContainer.terminalSize = ktermitem.terminalSize
|
||||||
onPaintedFontSizeChanged: terminalContainer._paintedFontSize = ktermitem.paintedFontSize
|
|
||||||
|
|
||||||
session: KSession {
|
session: KSession {
|
||||||
id: ksession
|
id: ksession
|
||||||
@ -94,11 +106,25 @@ Item{
|
|||||||
|
|
||||||
fontMetrics.font = font;
|
fontMetrics.font = font;
|
||||||
|
|
||||||
var scanline_spacing = shadersettings.font.lineSpacing;
|
var vertical_density = shadersettings.font.virtualResolution.height;
|
||||||
var scanline_height = fontMetrics.paintedHeight / shadersettings.font.virtualResolution.height;
|
var horizontal_density = shadersettings.font.virtualResolution.width;
|
||||||
|
|
||||||
|
var scanline_height = fontMetrics.paintedHeight / vertical_density;
|
||||||
|
var scanline_width = fontMetrics.paintedWidth / horizontal_density;
|
||||||
|
|
||||||
|
console.log("Font height: " + fontMetrics.paintedHeight)
|
||||||
|
|
||||||
|
var scanline_spacing = shadersettings.font.lineSpacing;
|
||||||
var line_spacing = Math.round(scanline_spacing * scanline_height);
|
var line_spacing = Math.round(scanline_spacing * scanline_height);
|
||||||
|
|
||||||
|
console.log("Scanline Height: " + scanline_height)
|
||||||
|
console.log("Line Spacing: " + line_spacing)
|
||||||
|
|
||||||
|
terminalContainer.scanlineHeight = scanline_height;
|
||||||
|
terminalContainer.scanlineWidth = scanline_width;
|
||||||
|
|
||||||
setLineSpacing(line_spacing);
|
setLineSpacing(line_spacing);
|
||||||
|
restartBlurredSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdatedImage: {blurredSource.live = true;livetimer.restart();}
|
onUpdatedImage: {blurredSource.live = true;livetimer.restart();}
|
||||||
@ -117,7 +143,6 @@ Item{
|
|||||||
MenuItem{action: fullscreenAction}
|
MenuItem{action: fullscreenAction}
|
||||||
}
|
}
|
||||||
MouseArea{
|
MouseArea{
|
||||||
|
|
||||||
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onWheel:
|
onWheel:
|
||||||
@ -166,10 +191,8 @@ Item{
|
|||||||
id: source
|
id: source
|
||||||
sourceItem: kterminal
|
sourceItem: kterminal
|
||||||
hideSource: true
|
hideSource: true
|
||||||
|
smooth: false
|
||||||
}
|
}
|
||||||
Loader{
|
|
||||||
anchors.fill: parent
|
|
||||||
active: mBlur !== 0
|
|
||||||
ShaderEffectSource{
|
ShaderEffectSource{
|
||||||
id: blurredSource
|
id: blurredSource
|
||||||
sourceItem: blurredterminal
|
sourceItem: blurredterminal
|
||||||
@ -185,29 +208,43 @@ Item{
|
|||||||
onTriggered: parent.live = false;
|
onTriggered: parent.live = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ShaderEffectSource{
|
||||||
|
id: finalSource
|
||||||
|
sourceItem: blurredterminal
|
||||||
|
sourceRect: frame.sourceRect
|
||||||
}
|
}
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
id: blurredterminal
|
id: blurredterminal
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
property variant source: source
|
property variant source: source
|
||||||
property variant blurredSource: (mBlur !== 0) ? blurredSource : undefined
|
property variant blurredSource: (mBlur !== 0) ? blurredSource : undefined
|
||||||
property size txt_size: Qt.size(width, height)
|
property size virtual_resolution: parent.virtual_resolution
|
||||||
|
property size delta: Qt.size((mScanlines == shadersettings.pixel_rasterization ? deltax : 0),
|
||||||
|
mScanlines != shadersettings.no_rasterization ? deltay : 0)
|
||||||
z: 2
|
z: 2
|
||||||
|
|
||||||
fragmentShader:
|
fragmentShader:
|
||||||
"uniform lowp float qt_Opacity;" +
|
"uniform lowp float qt_Opacity;" +
|
||||||
"uniform lowp sampler2D source;" +
|
"uniform lowp sampler2D source;" +
|
||||||
"uniform lowp vec2 txt_size;" +
|
"uniform highp vec2 delta;" +
|
||||||
|
|
||||||
"varying highp vec2 qt_TexCoord0;" +
|
"varying highp vec2 qt_TexCoord0;
|
||||||
|
|
||||||
|
uniform highp vec2 virtual_resolution;" +
|
||||||
|
|
||||||
(mBlur !== 0 ?
|
(mBlur !== 0 ?
|
||||||
"uniform lowp sampler2D blurredSource;"
|
"uniform lowp sampler2D blurredSource;"
|
||||||
: "") +
|
: "") +
|
||||||
|
|
||||||
"void main() {" +
|
"void main() {" +
|
||||||
"float color = texture2D(source, qt_TexCoord0).r * 256.0;" +
|
"vec2 coords = qt_TexCoord0;" +
|
||||||
|
(mScanlines != shadersettings.no_rasterization ? "
|
||||||
|
coords.y = floor(virtual_resolution.y * coords.y) / virtual_resolution.y;" +
|
||||||
|
(mScanlines == shadersettings.pixel_rasterization ? "
|
||||||
|
coords.x = floor(virtual_resolution.x * coords.x) / virtual_resolution.x;" : "")
|
||||||
|
: "") +
|
||||||
|
|
||||||
|
"float color = texture2D(source, coords + delta).r * 256.0;" +
|
||||||
(mBlur !== 0 ?
|
(mBlur !== 0 ?
|
||||||
"float blurredSourceColor = texture2D(blurredSource, qt_TexCoord0).r * 256.0;" +
|
"float blurredSourceColor = texture2D(blurredSource, qt_TexCoord0).r * 256.0;" +
|
||||||
"blurredSourceColor = blurredSourceColor - blurredSourceColor * " + (1.0 - motionBlurCoefficient) * fpsAttenuation+ ";" +
|
"blurredSourceColor = blurredSourceColor - blurredSourceColor * " + (1.0 - motionBlurCoefficient) * fpsAttenuation+ ";" +
|
||||||
@ -218,4 +255,65 @@ Item{
|
|||||||
"gl_FragColor = vec4(vec3(floor(color) / 256.0), 1.0);" +
|
"gl_FragColor = vec4(vec3(floor(color) / 256.0), 1.0);" +
|
||||||
"}"
|
"}"
|
||||||
}
|
}
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
//EFFECTS
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
//Bloom
|
||||||
|
Loader{
|
||||||
|
id: bloomEffectLoader
|
||||||
|
active: mBloom != 0
|
||||||
|
anchors.fill: parent
|
||||||
|
sourceComponent: FastBlur{
|
||||||
|
radius: 32
|
||||||
|
source: kterminal
|
||||||
|
transparentBorder: true
|
||||||
|
smooth: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loader{
|
||||||
|
id: bloomSourceLoader
|
||||||
|
active: mBloom != 0
|
||||||
|
sourceComponent: ShaderEffectSource{
|
||||||
|
sourceItem: bloomEffectLoader.item
|
||||||
|
hideSource: true
|
||||||
|
sourceRect: frame.sourceRect
|
||||||
|
smooth: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Scanlines
|
||||||
|
Loader{
|
||||||
|
id: scanlineEffectLoader
|
||||||
|
active: mScanlines != shadersettings.no_rasterization
|
||||||
|
anchors.fill: parent
|
||||||
|
sourceComponent: ShaderEffect {
|
||||||
|
property size virtual_resolution: terminalContainer.virtual_resolution
|
||||||
|
|
||||||
|
fragmentShader:
|
||||||
|
"uniform lowp float qt_Opacity;" +
|
||||||
|
|
||||||
|
"varying highp vec2 qt_TexCoord0;
|
||||||
|
uniform highp vec2 virtual_resolution;
|
||||||
|
|
||||||
|
float getScanlineIntensity(vec2 coords) {
|
||||||
|
float result = abs(sin(coords.y * virtual_resolution.y * "+Math.PI+"));" +
|
||||||
|
(mScanlines == shadersettings.pixel_rasterization ?
|
||||||
|
"result *= abs(sin(coords.x * virtual_resolution.x * "+Math.PI+"));" : "") + "
|
||||||
|
return result;
|
||||||
|
}" +
|
||||||
|
|
||||||
|
"void main() {" +
|
||||||
|
"gl_FragColor = vec4(getScanlineIntensity(qt_TexCoord0));" +
|
||||||
|
"}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loader{
|
||||||
|
id: scanlineSourceLoader
|
||||||
|
active: mScanlines != shadersettings.no_rasterization
|
||||||
|
sourceComponent: ShaderEffectSource{
|
||||||
|
sourceItem: scanlineEffectLoader.item
|
||||||
|
sourceRect: frame.sourceRect
|
||||||
|
hideSource: true
|
||||||
|
smooth: true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 3.0.1, 2014-05-31T21:19:31. -->
|
<!-- Written by QtCreator 3.0.1, 2014-06-06T20:31:03. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||||
|
@ -14,8 +14,8 @@ TerminalFrame{
|
|||||||
imageSource: "../images/black-frame.png"
|
imageSource: "../images/black-frame.png"
|
||||||
normalsSource: "../images/black-frame-normals.png"
|
normalsSource: "../images/black-frame-normals.png"
|
||||||
|
|
||||||
rectX: 15
|
rectX: 20
|
||||||
rectY: 15
|
rectY: 20
|
||||||
|
|
||||||
distortionCoefficient: 1.9
|
distortionCoefficient: 1.9
|
||||||
|
|
||||||
|
12
app/main.qml
12
app/main.qml
@ -133,16 +133,8 @@ ApplicationWindow{
|
|||||||
}
|
}
|
||||||
Terminal{
|
Terminal{
|
||||||
id: terminal
|
id: terminal
|
||||||
anchors.centerIn: parent
|
anchors.fill: parent
|
||||||
property int frameOffsetX: frame.item.addedWidth - frame.item.borderLeft - frame.item.borderRight
|
anchors.margins: 30
|
||||||
property int frameOffsetY: frame.item.addedHeight - frame.item.borderTop - frame.item.borderBottom
|
|
||||||
width: parent.width + frameOffsetX * shadersettings.window_scaling
|
|
||||||
height: parent.height + frameOffsetY * shadersettings.window_scaling
|
|
||||||
}
|
|
||||||
ShaderEffectSource{
|
|
||||||
id: theSource
|
|
||||||
sourceItem: terminal
|
|
||||||
sourceRect: frame.sourceRect
|
|
||||||
}
|
}
|
||||||
ShaderManager{
|
ShaderManager{
|
||||||
id: shadercontainer
|
id: shadercontainer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user