diff --git a/app/ShaderManager.qml b/app/ShaderManager.qml index 2c3a413..6b8cb82 100644 --- a/app/ShaderManager.qml +++ b/app/ShaderManager.qml @@ -26,7 +26,7 @@ ShaderEffect { property color background_color: shadersettings.background_color property variant source: terminal.theSource property variant bloomSource: terminal.bloomSource - property variant scanlineSource: terminal.scanlineSource + property variant rasterizationSource: terminal.rasterizationSource property size txt_Size: Qt.size(frame.sourceRect.width, frame.sourceRect.height) property real bloom: shadersettings.bloom_strength @@ -96,10 +96,8 @@ ShaderEffect { varying highp vec2 qt_TexCoord0; uniform highp vec4 font_color; - uniform highp vec4 background_color;" + - - (rasterization != shadersettings.no_rasterization ? " - uniform highp sampler2D scanlineSource;" : "") + + uniform highp vec4 background_color; + uniform highp sampler2D rasterizationSource;" + (bloom !== 0 ? " uniform highp sampler2D bloomSource;" : "") + @@ -174,9 +172,7 @@ ShaderEffect { "vec3 finalColor = mix(background_color, font_color, color).rgb;" + "finalColor = mix(finalColor * 1.1, vec3(0.0), 1.2 * distance * distance);" + - - (rasterization != shadersettings.no_rasterization ? " - finalColor *= texture2D(scanlineSource, coords).r;" : "") + + "finalColor *= texture2D(rasterizationSource, coords).r;" + (brightness_flickering !== 0 ? " finalColor *= brightness;" : "") + diff --git a/app/Terminal.qml b/app/Terminal.qml index 6f3e25c..5946f07 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -28,10 +28,14 @@ Item{ id: terminalContainer property variant theSource: finalSource property variant bloomSource: bloomSourceLoader.item - property variant scanlineSource: scanlineSourceLoader.item + property variant rasterizationSource: rasterizationEffectSource property alias kterminal: kterminal + signal sizeChanged + onWidthChanged: sizeChanged() + onHeightChanged: sizeChanged() + //The blur effect has to take into account the framerate property real fpsAttenuation: 60 / shadersettings.fps property real mBlur: shadersettings.motion_blur @@ -106,9 +110,9 @@ Item{ var scanline_spacing = shadersettings.font.lineSpacing; var line_spacing = Math.round(scanline_spacing * scanline_height); -// console.log("Font height: " + fontMetrics.paintedHeight) -// console.log("Scanline Height: " + scanline_height) -// console.log("Line Spacing: " + line_spacing) + // console.log("Font height: " + fontMetrics.paintedHeight) + // console.log("Scanline Height: " + scanline_height) + // console.log("Line Spacing: " + line_spacing) terminalContainer.scanlineHeight = scanline_height; terminalContainer.scanlineWidth = scanline_width; @@ -169,7 +173,7 @@ Item{ property real dright: frame.item.displacementRight property real dbottom: frame.item.displacementBottom - function correctDistortion(x, y){ + function correctDistortion(x, y){ x = x / width; y = y / height; @@ -282,40 +286,36 @@ Item{ smooth: false } } - //Scanlines - Loader{ - id: scanlineEffectLoader - active: mScanlines != shadersettings.no_rasterization + //Rasterization mask + ShaderEffect { + id: rasterizationEffect anchors.fill: parent - sourceComponent: ShaderEffect { - property size virtual_resolution: terminalContainer.virtual_resolution + property size virtual_resolution: terminalContainer.virtual_resolution - fragmentShader: - "uniform lowp float qt_Opacity;" + + fragmentShader: + "uniform lowp float qt_Opacity;" + - "varying highp vec2 qt_TexCoord0; + "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+"));" : "") + " + 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() {" + - "gl_FragColor = vec4(getScanlineIntensity(qt_TexCoord0));" + - "}" - } + "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 - } + ShaderEffectSource{ + id: rasterizationEffectSource + sourceItem: rasterizationEffect + sourceRect: frame.sourceRect + hideSource: true + smooth: true } }