From ef3303134d69c224d8f20a59921fe60aa6382814 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Wed, 9 Jul 2014 01:11:22 +0200 Subject: [PATCH] Edge borders are now slightly smoother. --- app/PreprocessedTerminal.qml | 78 +++++++++++++++++++++++++----------- app/app.qmlproject.user | 2 +- 2 files changed, 55 insertions(+), 25 deletions(-) diff --git a/app/PreprocessedTerminal.qml b/app/PreprocessedTerminal.qml index f33c5c2..2472422 100644 --- a/app/PreprocessedTerminal.qml +++ b/app/PreprocessedTerminal.qml @@ -342,42 +342,72 @@ Item{ } // RASTERIZATION ////////////////////////////////////////////////////////// - - ShaderEffect { - id: rasterizationEffect - anchors.fill: parent - property size virtual_resolution: terminalContainer.virtual_resolution + ShaderEffect{ + id: rasterizationContainer + width: frame.sourceRect.width + height: frame.sourceRect.height + property size offset: Qt.size(width - rasterizationEffect.width, height - rasterizationEffect.height) + property size txtRes: Qt.size(width, height) blending: false fragmentShader: - "uniform lowp float qt_Opacity;" + + "uniform lowp float qt_Opacity; + uniform highp vec2 offset; + uniform highp vec2 txtRes;" + - "varying highp vec2 qt_TexCoord0; - uniform highp vec2 virtual_resolution; + "varying highp vec2 qt_TexCoord0;" + - float getScanlineIntensity(vec2 coords) { - float result = 1.0;" + - (mScanlines != shadersettings.no_rasterization ? - "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() {" + + "float color = 1.0; + color *= smoothstep(0.0, offset.x / txtRes.x, qt_TexCoord0.x); + color *= smoothstep(0.0, offset.y / txtRes.y, qt_TexCoord0.y); + color *= smoothstep(0.0, offset.x / txtRes.x, 1.0 - qt_TexCoord0.x); + color *= smoothstep(0.0, offset.y / txtRes.y, 1.0 - qt_TexCoord0.y);" + - "void main() {" + - "float distance = length(vec2(0.5) - qt_TexCoord0);" + + "float distance = length(vec2(0.5) - qt_TexCoord0);" + + "color = mix(color, 0.0, 1.2 * distance * distance);" + - "float color = getScanlineIntensity(qt_TexCoord0);" + - "color = mix(color, 0.0, 1.2 * distance * distance);" + + "gl_FragColor.a = color;" + + "}" - "gl_FragColor.a = color;" + - "}" + ShaderEffect { + id: rasterizationEffect + width: terminalContainer.width + height: terminalContainer.height + anchors.centerIn: parent + property size virtual_resolution: terminalContainer.virtual_resolution + + blending: false + + fragmentShader: + "uniform lowp float qt_Opacity;" + + + "varying highp vec2 qt_TexCoord0; + uniform highp vec2 virtual_resolution; + + float getScanlineIntensity(vec2 coords) { + float result = 1.0;" + + (mScanlines != shadersettings.no_rasterization ? + "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() {" + + "float color = getScanlineIntensity(qt_TexCoord0);" + + + "float distance = length(vec2(0.5) - qt_TexCoord0);" + + "color = mix(color, 0.0, 1.2 * distance * distance);" + + + "gl_FragColor.a = color;" + + "}" + } } ShaderEffectSource{ id: rasterizationEffectSource - sourceItem: rasterizationEffect - sourceRect: frame.sourceRect + sourceItem: rasterizationContainer hideSource: true smooth: true format: ShaderEffectSource.Alpha diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index 4444003..4f5be78 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget