mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2026-02-08 00:32:27 +00:00
218 lines
8.4 KiB
QML
218 lines
8.4 KiB
QML
/*******************************************************************************
|
|
* Copyright (c) 2013-2021 "Filippo Scognamiglio"
|
|
* https://github.com/Swordfish90/cool-retro-term
|
|
*
|
|
* This file is part of cool-retro-term.
|
|
*
|
|
* cool-retro-term is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*******************************************************************************/
|
|
|
|
import QtQuick 2.2
|
|
|
|
import "utils.js" as Utils
|
|
|
|
Item {
|
|
property ShaderEffectSource source
|
|
property BurnInEffect burnInEffect
|
|
property ShaderEffectSource bloomSource
|
|
|
|
property color fontColor: appSettings.fontColor
|
|
property color backgroundColor: appSettings.backgroundColor
|
|
|
|
property real screenCurvature: appSettings.screenCurvature * appSettings.screenCurvatureSize
|
|
|
|
property real chromaColor: appSettings.chromaColor
|
|
|
|
property real ambientLight: appSettings.ambientLight * 0.2
|
|
|
|
property size virtualResolution
|
|
property size screenResolution
|
|
|
|
property real _screenDensity: Math.min(
|
|
screenResolution.width / virtualResolution.width,
|
|
screenResolution.height / virtualResolution.height
|
|
)
|
|
|
|
ShaderEffect {
|
|
id: dynamicShader
|
|
|
|
property ShaderEffectSource screenBuffer: frameBuffer
|
|
property ShaderEffectSource burnInSource: burnInEffect.source
|
|
property ShaderEffectSource frameSource: terminalFrameLoader.item
|
|
|
|
property color fontColor: parent.fontColor
|
|
property color backgroundColor: parent.backgroundColor
|
|
property real screenCurvature: parent.screenCurvature
|
|
property real chromaColor: parent.chromaColor
|
|
property real ambientLight: parent.ambientLight
|
|
|
|
property real flickering: appSettings.flickering
|
|
property real horizontalSync: appSettings.horizontalSync
|
|
property real horizontalSyncStrength: Utils.lint(0.05, 0.35, horizontalSync)
|
|
property real glowingLine: appSettings.glowingLine * 0.2
|
|
|
|
// Fast burnin properties
|
|
property real burnIn: appSettings.burnIn
|
|
property real burnInLastUpdate: burnInEffect.lastUpdate
|
|
property real burnInTime: burnInEffect.burnInFadeTime
|
|
|
|
property real jitter: appSettings.jitter
|
|
property size jitterDisplacement: Qt.size(0.007 * jitter, 0.002 * jitter)
|
|
property real shadowLength: 0.25 * screenCurvature * Utils.lint(0.50, 1.5, ambientLight)
|
|
property real staticNoise: appSettings.staticNoise
|
|
property size scaleNoiseSize: Qt.size((width * 0.75) / (noiseTexture.width * appSettings.windowScaling * appSettings.totalFontScaling),
|
|
(height * 0.75) / (noiseTexture.height * appSettings.windowScaling * appSettings.totalFontScaling))
|
|
|
|
property size virtualResolution: parent.virtualResolution
|
|
|
|
// Rasterization might display oversamping issues if virtual resolution is close to physical display resolution.
|
|
// We progressively disable rasterization from 4x up to 2x resolution.
|
|
property real rasterizationIntensity: Utils.smoothstep(2.0, 4.0, _screenDensity)
|
|
property int rasterizationMode: appSettings.rasterization
|
|
|
|
property real displayTerminalFrame: appSettings._frameSize > 0 || appSettings.screenCurvature > 0
|
|
|
|
property real time: timeManager.time
|
|
property ShaderEffectSource noiseSource: noiseShaderSource
|
|
|
|
// Extra uniforms expected by the shared uniform block
|
|
property real frameShadowCoeff: 0
|
|
property color frameColor: backgroundColor
|
|
property real frameSize: appSettings.frameSize
|
|
property real prevLastUpdate: burnInEffect.prevLastUpdate
|
|
property real screen_brightness: Utils.lint(0.5, 1.5, appSettings.brightness)
|
|
property real bloom: appSettings.bloom
|
|
property real rbgShift: (appSettings.rbgShift / Math.max(width, 1)) * appSettings.totalFontScaling
|
|
property real frameShininess: appSettings.frameShininess
|
|
|
|
anchors.fill: parent
|
|
blending: false
|
|
|
|
Image {
|
|
id: noiseTexture
|
|
source: "images/allNoise512.png"
|
|
width: 512
|
|
height: 512
|
|
fillMode: Image.Tile
|
|
visible: false
|
|
}
|
|
ShaderEffectSource {
|
|
id: noiseShaderSource
|
|
sourceItem: noiseTexture
|
|
wrapMode: ShaderEffectSource.Repeat
|
|
visible: false
|
|
smooth: true
|
|
}
|
|
|
|
vertexShader: "qrc:/shaders/terminal_dynamic.vert.qsb"
|
|
fragmentShader: "qrc:/shaders/terminal_dynamic.frag.qsb"
|
|
|
|
onStatusChanged: if (log) console.log(log)
|
|
}
|
|
|
|
Loader {
|
|
id: terminalFrameLoader
|
|
|
|
active: dynamicShader.displayTerminalFrame
|
|
|
|
width: staticShader.width
|
|
height: staticShader.height
|
|
|
|
sourceComponent: ShaderEffectSource {
|
|
|
|
sourceItem: terminalFrame
|
|
hideSource: true
|
|
visible: false
|
|
format: ShaderEffectSource.RGBA
|
|
|
|
TerminalFrame {
|
|
id: terminalFrame
|
|
blending: false
|
|
anchors.fill: parent
|
|
}
|
|
}
|
|
}
|
|
|
|
ShaderLibrary {
|
|
id: shaderLibrary
|
|
}
|
|
|
|
ShaderEffect {
|
|
id: staticShader
|
|
|
|
width: parent.width * appSettings.windowScaling
|
|
height: parent.height * appSettings.windowScaling
|
|
|
|
property ShaderEffectSource source: parent.source
|
|
property ShaderEffectSource bloomSource: parent.bloomSource
|
|
|
|
property color fontColor: parent.fontColor
|
|
property color backgroundColor: parent.backgroundColor
|
|
property real bloom: bloomSource ? appSettings.bloom * 2.5 : 0
|
|
|
|
property real screenCurvature: parent.screenCurvature
|
|
|
|
property real chromaColor: appSettings.chromaColor;
|
|
|
|
property real rbgShift: (appSettings.rbgShift / width) * appSettings.totalFontScaling
|
|
|
|
property int rasterization: appSettings.rasterization
|
|
|
|
property real screen_brightness: Utils.lint(0.5, 1.5, appSettings.brightness)
|
|
|
|
property real ambientLight: parent.ambientLight
|
|
|
|
property size virtualResolution: parent.virtualResolution
|
|
property real frameShininess: appSettings.frameShininess
|
|
|
|
// Extra uniforms to match shared uniform block
|
|
property real time: timeManager.time
|
|
property real shadowLength: 0
|
|
property real rasterizationIntensity: Utils.smoothstep(2.0, 4.0, _screenDensity)
|
|
property int rasterizationMode: appSettings.rasterization
|
|
property real burnInLastUpdate: burnInEffect.lastUpdate
|
|
property real burnInTime: burnInEffect.burnInFadeTime
|
|
property real burnIn: appSettings.burnIn
|
|
property real staticNoise: appSettings.staticNoise
|
|
property real glowingLine: appSettings.glowingLine * 0.2
|
|
property size jitterDisplacement: Qt.size(0, 0)
|
|
property real jitter: appSettings.jitter
|
|
property real horizontalSync: appSettings.horizontalSync
|
|
property real horizontalSyncStrength: Utils.lint(0.05, 0.35, horizontalSync)
|
|
property real flickering: appSettings.flickering
|
|
property real displayTerminalFrame: dynamicShader.displayTerminalFrame
|
|
property size scaleNoiseSize: Qt.size((width * 0.75) / (512 * appSettings.windowScaling * appSettings.totalFontScaling),
|
|
(height * 0.75) / (512 * appSettings.windowScaling * appSettings.totalFontScaling))
|
|
property real frameShadowCoeff: 0
|
|
property color frameColor: backgroundColor
|
|
property real frameSize: appSettings.frameSize
|
|
property real prevLastUpdate: burnInEffect.prevLastUpdate
|
|
|
|
blending: false
|
|
visible: false
|
|
|
|
vertexShader: "qrc:/shaders/passthrough.vert.qsb"
|
|
fragmentShader: "qrc:/shaders/terminal_static.frag.qsb"
|
|
|
|
onStatusChanged: if (log) console.log(log)
|
|
}
|
|
|
|
ShaderEffectSource {
|
|
id: frameBuffer
|
|
visible: false
|
|
sourceItem: staticShader
|
|
hideSource: true
|
|
}
|
|
}
|