1
0
mirror of https://github.com/Swordfish90/cool-retro-term.git synced 2026-02-08 00:32:27 +00:00

10 Commits
1.2.0 ... qt6

Author SHA1 Message Date
Filippo Scognamiglio
002c85e35f Fix missing key repeats on macos. 2025-12-13 22:55:24 +01:00
Filippo Scognamiglio
fed2bf21fe Remove warnings related qt6 signal handlers. 2025-12-10 23:20:31 +01:00
Filippo Scognamiglio
3f51308057 Improve noise scale and frameskip for effects. 2025-12-10 23:14:15 +01:00
Filippo Scognamiglio
70d7d1b9ce Build qbs files with qmake. 2025-12-10 23:13:38 +01:00
Filippo Scognamiglio
c1082f2e3e Fix sizing issues with fractional scaling. 2025-12-10 00:41:16 +01:00
Filippo Scognamiglio
7038b30381 Migrate all shaders to compiled qsb files. 2025-12-09 23:51:39 +01:00
Filippo Scognamiglio
1d73abda51 Make it compile with Qt6. 2025-12-09 10:41:41 +01:00
Filippo Scognamiglio
f157648d1e Merge pull request #711 from razziel89/feature/appimage-in-github-actions
Feature/appimage in GitHub actions
2022-03-31 07:18:37 +02:00
Torsten Sachse
d4baaeccfc Undo unneeded code changes 2022-03-29 08:22:59 +02:00
Torsten Sachse
d412b66c6e Add github action for building an appimage 2022-03-29 08:16:02 +02:00
35 changed files with 977 additions and 678 deletions

98
.github/workflows/appimage.yml vendored Normal file
View File

@@ -0,0 +1,98 @@
name: "ci"
on:
push:
tags: "**"
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
appimage:
runs-on: ubuntu-18.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: true
- name: Install dependencies
run: |
sudo add-apt-repository -y ppa:beineri/opt-qt-5.15.2-bionic
sudo apt-get update -qq
sudo apt-get install -y \
build-essential make wget libgl1-mesa-dev \
qt515declarative qt515graphicaleffects \
qt515quickcontrols qt515quickcontrols2
- name: Download QT appimage builder
run: |
wget -c -O linuxdeployqt.AppImage \
https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
chmod a+x linuxdeployqt.AppImage
- name: Build project
run: |
source /opt/qt*/bin/qt*-env.sh && \
qmake -v && \
qmake CONFIG+=release PREFIX=/usr && \
make -j$(nproc)
- name: Install to appdir
run: |
source /opt/qt*/bin/qt*-env.sh && \
make INSTALL_ROOT=appdir -j$(nproc) install
- name: Extract version number
run: |
# Extract version for linuxdeployqt to name the file. Use the tag as
# release name but remove prefix.
echo "VERSION=$(echo '${{ github.ref }}' | sed 's;.*/;;')" >> $GITHUB_ENV
- name: Build appimage directory
run: |
mkdir -p \
appdir/usr/bin \
appdir/usr/lib \
appdir/usr/share/applications \
appdir/usr/share/metainfo \
appdir/usr/share/icons/hicolor/128x128/apps
cp cool-retro-term appdir/usr/bin/
cp cool-retro-term.desktop appdir/usr/share/applications/
cp packaging/appdata/cool-retro-term.appdata.xml appdir/usr/share/metainfo/
cp app/icons/128x128/cool-retro-term.png appdir/usr/share/icons/hicolor/128x128/apps/
cp -r ./app/qml appdir/usr/
# Workaround for https://github.com/probonopd/linuxdeployqt/issues/78
cp -r ./qmltermwidget/QMLTermWidget appdir/usr/qml/
find appdir | sort
- name: Build appimage
run: |
source /opt/qt*/bin/qt*-env.sh && \
./linuxdeployqt.AppImage appdir/usr/share/applications/cool-retro-term.desktop \
-verbose=1 -appimage \
-qmldir=./app/qml/ \
-qmldir=./qmltermwidget/
env:
# Unset environment variables
QTDIR:
QT_PLUGIN_PATH:
LD_LIBRARY_PATH:
- name: Upload release
uses: softprops/action-gh-release@v1
with:
body: appimage release
files: ./**/Cool_Retro_Term-*-x86_64.AppImage
- name: Clean up
if: always()
run: |
find appdir -executable -type f -exec ldd {} \; | grep " => /usr" | cut -d " " -f 2-3 | sort | uniq
make clean
rm -rf appdir

1
.gitignore vendored
View File

@@ -43,6 +43,7 @@ Makefile*
# Excludes compiled files
imports
cool-retro-term
build
# Mac OSX

View File

@@ -15,6 +15,23 @@ macx:ICON = icons/crt.icns
RESOURCES += qml/resources.qrc
# Shader compilation (Qt Shader Baker)
QSB_BIN = $$[QT_HOST_BINS]/qsb
isEmpty(QSB_BIN): QSB_BIN = $$[QT_INSTALL_BINS]/qsb
SHADERS_DIR = $${_PRO_FILE_PWD_}/shaders
SHADERS += $$files($$SHADERS_DIR/*.frag) $$files($$SHADERS_DIR/*.vert)
qsb.input = SHADERS
qsb.output = ../../app/shaders/${QMAKE_FILE_NAME}.qsb
qsb.commands = $$QSB_BIN --glsl \"100 es,120,150\" --hlsl 50 --msl 12 --qt6 -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
qsb.clean = $$qsb.output
qsb.name = qsb ${QMAKE_FILE_IN}
qsb.variable_out = QSB_FILES
QMAKE_EXTRA_COMPILERS += qsb
PRE_TARGETDEPS += $$QSB_FILES
OTHER_FILES += $$SHADERS $$QSB_FILES
#########################################
## INTALLS
#########################################

View File

@@ -17,6 +17,10 @@
#include <fileio.h>
#include <monospacefontmanager.h>
#if defined(Q_OS_MAC)
#include <CoreFoundation/CoreFoundation.h>
#endif
QString getNamedArgument(QStringList args, QString name, QString defaultName)
{
int index = args.indexOf(name);
@@ -31,33 +35,37 @@ QString getNamedArgument(QStringList args, QString name)
int main(int argc, char *argv[])
{
// Some environmental variable are necessary on certain platforms.
// This disables QT appmenu under Ubuntu, which is not working with QML apps.
setenv("QT_QPA_PLATFORMTHEME", "", 1);
// Disable Connections slot warnings
QLoggingCategory::setFilterRules("qt.qml.connections.warning=false");
#if defined (Q_OS_LINUX)
setenv("QSG_RENDER_LOOP", "threaded", 0);
#endif
// TODO FILIPPO... This should not be hardcoded but handled as a fallback of sort!
QQuickStyle::setStyle("Material");
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
// #if defined (Q_OS_LINUX)
// setenv("QSG_RENDER_LOOP", "threaded", 0);
// #endif
#if defined(Q_OS_MAC)
// This allows UTF-8 characters usage in OSX.
setenv("LC_CTYPE", "UTF-8", 1);
// Ensure key repeat works for letter keys (disable macOS press-and-hold for this app).
CFPreferencesSetAppValue(CFSTR("ApplePressAndHoldEnabled"), kCFBooleanFalse, kCFPreferencesCurrentApplication);
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
#endif
if (argc>1 && (!strcmp(argv[1],"-h") || !strcmp(argv[1],"--help"))) {
QTextStream cout(stdout, QIODevice::WriteOnly);
cout << "Usage: " << argv[0] << " [--default-settings] [--workdir <dir>] [--program <prog>] [-p|--profile <prof>] [--fullscreen] [-h|--help]" << endl;
cout << " --default-settings Run cool-retro-term with the default settings" << endl;
cout << " --workdir <dir> Change working directory to 'dir'" << endl;
cout << " -e <cmd> Command to execute. This option will catch all following arguments, so use it as the last option." << endl;
cout << " -T <title> Set window title to 'title'." << endl;
cout << " --fullscreen Run cool-retro-term in fullscreen." << endl;
cout << " -p|--profile <prof> Run cool-retro-term with the given profile." << endl;
cout << " -h|--help Print this help." << endl;
cout << " --verbose Print additional information such as profiles and settings." << endl;
cout << "Usage: " << argv[0] << " [--default-settings] [--workdir <dir>] [--program <prog>] [-p|--profile <prof>] [--fullscreen] [-h|--help]" << Qt::endl;
cout << " --default-settings Run cool-retro-term with the default settings" << Qt::endl;
cout << " --workdir <dir> Change working directory to 'dir'" << Qt::endl;
cout << " -e <cmd> Command to execute. This option will catch all following arguments, so use it as the last option." << Qt::endl;
cout << " -T <title> Set window title to 'title'." << Qt::endl;
cout << " --fullscreen Run cool-retro-term in fullscreen." << Qt::endl;
cout << " -p|--profile <prof> Run cool-retro-term with the given profile." << Qt::endl;
cout << " -h|--help Print this help." << Qt::endl;
cout << " --verbose Print additional information such as profiles and settings." << Qt::endl;
return 0;
}
@@ -65,7 +73,7 @@ int main(int argc, char *argv[])
if (argc>1 && (!strcmp(argv[1],"-v") || !strcmp(argv[1],"--version"))) {
QTextStream cout(stdout, QIODevice::WriteOnly);
cout << "cool-retro-term " << appVersion << endl;
cout << "cool-retro-term " << appVersion << Qt::endl;
return 0;
}

View File

@@ -31,8 +31,8 @@ QtObject {
readonly property real minimumFontScaling: 0.25
readonly property real maximumFontScaling: 2.50
readonly property real minBurnInFadeTime: 160
readonly property real maxBurnInFadeTime: 1600
readonly property real minBurnInFadeTime: 0.16
readonly property real maxBurnInFadeTime: 1.6
property bool isMacOS: Qt.platform.os === "osx"
@@ -50,7 +50,7 @@ QtObject {
property bool showTerminalSize: true
property real windowScaling: 1.0
property real fps: 20
property int effectsFrameSkip: 2
property bool verbose: false
property real bloomQuality: 0.5
@@ -229,7 +229,7 @@ QtObject {
function composeSettingsString() {
var settings = {
"fps": fps,
"effectsFrameSkip": effectsFrameSkip,
"x": x,
"y": y,
"width": width,
@@ -315,7 +315,7 @@ QtObject {
showTerminalSize = settings.showTerminalSize
!== undefined ? settings.showTerminalSize : showTerminalSize
fps = settings.fps !== undefined ? settings.fps : fps
effectsFrameSkip = settings.effectsFrameSkip !== undefined ? settings.effectsFrameSkip : effectsFrameSkip
windowScaling = settings.windowScaling
!== undefined ? settings.windowScaling : windowScaling

View File

@@ -102,58 +102,50 @@ Loader {
}
}
ShaderLibrary {
id: shaderLibrary
}
ShaderEffect {
id: burnInShaderEffect
property variant txt_source: kterminalSource
property variant burnInSource: burnInEffectSource
property real burnInTime: burnInFadeTime
property real lastUpdate: burnInEffect.lastUpdate
property real burnInLastUpdate: burnInEffect.lastUpdate
property real prevLastUpdate: burnInEffect.prevLastUpdate
anchors.fill: parent
blending: false
fragmentShader:
"#ifdef GL_ES
precision mediump float;
#endif\n" +
// Extra uniforms required by shared block
property real qt_Opacity: 1.0
property real time: timeManager.time
property color fontColor: appSettings.fontColor
property color backgroundColor: appSettings.backgroundColor
property real shadowLength: 0
property size virtualResolution: Qt.size(width, height)
property real rasterizationIntensity: 0
property int rasterizationMode: 0
property real burnIn: appSettings.burnIn
property real staticNoise: 0
property real screenCurvature: 0
property real glowingLine: 0
property real chromaColor: 0
property size jitterDisplacement: Qt.size(0, 0)
property real ambientLight: 0
property real jitter: 0
property real horizontalSync: 0
property real horizontalSyncStrength: 0
property real flickering: 0
property real displayTerminalFrame: 0
property size scaleNoiseSize: Qt.size(0, 0)
property real screen_brightness: 1.0
property real bloom: 0
property real rbgShift: 0
property real screenShadowCoeff: 0
property real frameShadowCoeff: 0
property color frameColor: backgroundColor
property size margin: Qt.size(0, 0)
"uniform lowp float qt_Opacity;" +
"uniform lowp sampler2D txt_source;" +
"varying highp vec2 qt_TexCoord0;
uniform lowp sampler2D burnInSource;
uniform highp float burnInTime;
uniform highp float lastUpdate;
uniform highp float prevLastUpdate;" +
shaderLibrary.rgb2grey +
"void main() {
vec2 coords = qt_TexCoord0;
vec3 txtColor = texture2D(txt_source, coords).rgb;
vec4 accColor = texture2D(burnInSource, coords);
float prevMask = accColor.a;
float currMask = rgb2grey(txtColor);
highp float blurDecay = clamp((lastUpdate - prevLastUpdate) * burnInTime, 0.0, 1.0);
blurDecay = max(0.0, blurDecay - prevMask);
vec3 blurColor = accColor.rgb - vec3(blurDecay);
vec3 color = max(blurColor, txtColor);
gl_FragColor = vec4(color, currMask);
}
"
fragmentShader: "qrc:/shaders/burn_in.frag.qsb"
vertexShader: "qrc:/shaders/passthrough.vert.qsb"
onStatusChanged: if (log) console.log(log) //Print warning messages
}

View File

@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
import QtQuick 2.2
import QtQuick.Dialogs 1.1
import QtQuick.Dialogs
Item {
id: rootItem
@@ -31,11 +31,13 @@ Item {
id: colorDialog
title: qsTr("Choose a color")
modality: Qt.ApplicationModal
visible: false
selectedColor: rootItem.color
//This is a workaround to a Qt 5.2 bug.
onColorChanged: if (!appSettings.isMacOS) colorSelected(color)
onAccepted: if (appSettings.isMacOS) colorSelected(color)
onSelectedColorChanged: {
if (!appSettings.isMacOS && visible)
colorSelected(selectedColor)
}
onAccepted: colorSelected(selectedColor)
}
Rectangle {
anchors.fill: parent
@@ -57,6 +59,6 @@ Item {
}
MouseArea {
anchors.fill: parent
onClicked: colorDialog.visible = true
onClicked: colorDialog.open()
}
}

View File

@@ -21,7 +21,7 @@ import QtQuick 2.2
import QtQuick.Window 2.0
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.1
import QtQuick.Dialogs
Window {
id: insertnamedialog

View File

@@ -208,31 +208,31 @@ Item{
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
anchors.fill: parent
cursorShape: kterminal.terminalUsesMouse ? Qt.ArrowCursor : Qt.IBeamCursor
onWheel:{
if(wheel.modifiers & Qt.ControlModifier){
onWheel: function(wheel) {
if (wheel.modifiers & Qt.ControlModifier) {
wheel.angleDelta.y > 0 ? zoomIn.trigger() : zoomOut.trigger();
} else {
var coord = correctDistortion(wheel.x, wheel.y);
kterminal.simulateWheel(coord.x, coord.y, wheel.buttons, wheel.modifiers, wheel.angleDelta);
}
}
onDoubleClicked: {
onDoubleClicked: function(mouse) {
var coord = correctDistortion(mouse.x, mouse.y);
kterminal.simulateMouseDoubleClick(coord.x, coord.y, mouse.button, mouse.buttons, mouse.modifiers);
}
onPressed: {
if((!kterminal.terminalUsesMouse || mouse.modifiers & Qt.ShiftModifier) && mouse.button == Qt.RightButton) {
onPressed: function(mouse) {
if ((!kterminal.terminalUsesMouse || mouse.modifiers & Qt.ShiftModifier) && mouse.button == Qt.RightButton) {
contextmenu.popup();
} else {
var coord = correctDistortion(mouse.x, mouse.y);
kterminal.simulateMousePress(coord.x, coord.y, mouse.button, mouse.buttons, mouse.modifiers)
}
}
onReleased: {
onReleased: function(mouse) {
var coord = correctDistortion(mouse.x, mouse.y);
kterminal.simulateMouseRelease(coord.x, coord.y, mouse.button, mouse.buttons, mouse.modifiers);
}
onPositionChanged: {
onPositionChanged: function(mouse) {
var coord = correctDistortion(mouse.x, mouse.y);
kterminal.simulateMouseMove(coord.x, coord.y, mouse.button, mouse.buttons, mouse.modifiers);
}

View File

@@ -73,24 +73,17 @@ ColumnLayout {
Slider {
Layout.fillWidth: true
Layout.columnSpan: 2
id: fpsSlider
onValueChanged: {
if (enabled) {
appSettings.fps = value !== 60 ? value + 1 : 0
}
}
id: effectsFpsSlider
onValueChanged: appSettings.effectsFrameSkip = Math.round(value)
stepSize: 1
enabled: false
Component.onCompleted: {
from = 0
to = 60
value = appSettings.fps !== 0 ? appSettings.fps - 1 : 60
enabled = true
}
enabled: true
from: 5
to: 1
value: appSettings.effectsFrameSkip
}
SizedLabel {
text: appSettings.fps !== 0 ? appSettings.fps : qsTr("Max")
text: Math.round(100 / Math.max(1, Math.round(effectsFpsSlider.value))) + "%"
}
Label {
text: qsTr("Texture Quality")
@@ -99,15 +92,11 @@ ColumnLayout {
id: txtslider
Layout.fillWidth: true
Layout.columnSpan: 2
onValueChanged: if (enabled)
appSettings.windowScaling = value
onValueChanged: appSettings.windowScaling = value
stepSize: 0.05
enabled: false
Component.onCompleted: {
from = 0.25 //Without this value gets set to 0.5
value = appSettings.windowScaling
enabled = true
}
enabled: true
from: 0.25
value: appSettings.windowScaling
}
SizedLabel {
text: Math.round(txtslider.value * 100) + "%"
@@ -120,15 +109,11 @@ ColumnLayout {
Layout.fillWidth: true
Layout.columnSpan: 2
id: bloomSlider
onValueChanged: if (enabled)
appSettings.bloomQuality = value
onValueChanged: appSettings.bloomQuality = value
stepSize: 0.05
enabled: false
Component.onCompleted: {
from = 0.25
value = appSettings.bloomQuality
enabled = true
}
enabled: true
from: 0.25
value: appSettings.bloomQuality
}
SizedLabel {
text: Math.round(bloomSlider.value * 100) + "%"
@@ -141,15 +126,11 @@ ColumnLayout {
Layout.fillWidth: true
id: burnInSlider
Layout.columnSpan: 2
onValueChanged: if (enabled)
appSettings.burnInQuality = value
onValueChanged: appSettings.burnInQuality = value
stepSize: 0.05
enabled: false
Component.onCompleted: {
from = 0.25
value = appSettings.burnInQuality
enabled = true
}
enabled: true
from: 0.25
value: appSettings.burnInQuality
}
SizedLabel {
text: Math.round(burnInSlider.value * 100) + "%"

View File

@@ -33,53 +33,53 @@ ColumnLayout {
CheckableSlider {
name: qsTr("Bloom")
onNewValue: appSettings.bloom = newValue
onNewValue: function(newValue) { appSettings.bloom = newValue }
value: appSettings.bloom
}
CheckableSlider {
name: qsTr("BurnIn")
onNewValue: appSettings.burnIn = newValue
onNewValue: function(newValue) { appSettings.burnIn = newValue }
value: appSettings.burnIn
}
CheckableSlider {
name: qsTr("Static Noise")
onNewValue: appSettings.staticNoise = newValue
onNewValue: function(newValue) { appSettings.staticNoise = newValue }
value: appSettings.staticNoise
}
CheckableSlider {
name: qsTr("Jitter")
onNewValue: appSettings.jitter = newValue
onNewValue: function(newValue) { appSettings.jitter = newValue }
value: appSettings.jitter
}
CheckableSlider {
name: qsTr("Glow Line")
onNewValue: appSettings.glowingLine = newValue
onNewValue: function(newValue) { appSettings.glowingLine = newValue }
value: appSettings.glowingLine
}
CheckableSlider {
name: qsTr("Screen Curvature")
onNewValue: appSettings.screenCurvature = newValue
onNewValue: function(newValue) { appSettings.screenCurvature = newValue }
value: appSettings.screenCurvature
}
CheckableSlider {
name: qsTr("Ambient Light")
onNewValue: appSettings.ambientLight = newValue
onNewValue: function(newValue) { appSettings.ambientLight = newValue }
value: appSettings.ambientLight
enabled: appSettings.framesIndex !== 0
}
CheckableSlider {
name: qsTr("Flickering")
onNewValue: appSettings.flickering = newValue
onNewValue: function(newValue) { appSettings.flickering = newValue }
value: appSettings.flickering
}
CheckableSlider {
name: qsTr("Horizontal Sync")
onNewValue: appSettings.horizontalSync = newValue
onNewValue: function(newValue) { appSettings.horizontalSync = newValue }
value: appSettings.horizontalSync
}
CheckableSlider {
name: qsTr("RGB Shift")
onNewValue: appSettings.rbgShift = newValue
onNewValue: function(newValue) { appSettings.rbgShift = newValue }
value: appSettings.rbgShift
}
}

View File

@@ -20,7 +20,7 @@
import QtQuick 2.2
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.1
import QtQuick.Dialogs
ColumnLayout {
GroupBox {
@@ -237,6 +237,7 @@ ColumnLayout {
MessageDialog {
id: messageDialog
title: qsTr("File Error")
buttons: MessageDialog.Ok
onAccepted: {
messageDialog.close()
}
@@ -248,10 +249,8 @@ ColumnLayout {
sourceComponent: FileDialog {
nameFilters: ["Json files (*.json)"]
selectMultiple: false
selectFolder: false
selectExisting: fileDialog.selectExisting
onAccepted: callBack(fileUrl)
fileMode: fileDialog.selectExisting ? FileDialog.OpenFile : FileDialog.SaveFile
onAccepted: callBack(selectedFile)
}
onSelectExistingChanged: reload()

View File

@@ -140,12 +140,12 @@ ColumnLayout {
Layout.fillWidth: true
CheckableSlider {
name: qsTr("Chroma Color")
onNewValue: appSettings.chromaColor = newValue
onNewValue: function(newValue) { appSettings.chromaColor = newValue }
value: appSettings.chromaColor
}
CheckableSlider {
name: qsTr("Saturation Color")
onNewValue: appSettings.saturationColor = newValue
onNewValue: function(newValue) { appSettings.saturationColor = newValue }
value: appSettings.saturationColor
enabled: appSettings.chromaColor !== 0
}

View File

@@ -22,7 +22,7 @@ import QtQuick 2.2
import QtQuick.Controls 2.1
import QtQuick.Window 2.1
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.1
import QtQuick.Dialogs
Window {
id: settings_window

View File

@@ -19,7 +19,6 @@
*******************************************************************************/
import QtQuick 2.2
import QtGraphicalEffects 1.0
import "utils.js" as Utils
@@ -48,8 +47,6 @@ Item {
ShaderEffect {
id: dynamicShader
property ShaderLibrary shaderLibrary: ShaderLibrary { }
property ShaderEffectSource screenBuffer: frameBuffer
property ShaderEffectSource burnInSource: burnInEffect.source
property ShaderEffectSource frameSource: terminalFrameLoader.item
@@ -82,19 +79,26 @@ Item {
// 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._frameMargin > 0 || appSettings.screenCurvature > 0
property real time: timeManager.time
property ShaderEffectSource noiseSource: noiseShaderSource
// If something goes wrong activate the fallback version of the shader.
property bool fallBack: false
// Extra uniforms expected by the shared uniform block
property real screenShadowCoeff: 0
property real frameShadowCoeff: 0
property color frameColor: backgroundColor
property size margin: Qt.size(0, 0)
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
anchors.fill: parent
blending: false
//Smooth random texture used for flickering effect.
Image {
id: noiseTexture
source: "images/allNoise512.png"
@@ -111,232 +115,10 @@ Item {
smooth: true
}
//Print the number with a reasonable precision for the shader.
function str(num){
return num.toFixed(8);
}
vertexShader: "qrc:/shaders/terminal_dynamic.vert.qsb"
fragmentShader: "qrc:/shaders/terminal_dynamic.frag.qsb"
vertexShader: "
uniform highp mat4 qt_Matrix;
uniform highp float time;
attribute highp vec4 qt_Vertex;
attribute highp vec2 qt_MultiTexCoord0;
varying highp vec2 qt_TexCoord0;" +
(!fallBack ? "
uniform sampler2D noiseSource;" : "") +
(!fallBack && flickering !== 0.0 ?"
varying lowp float brightness;
uniform lowp float flickering;" : "") +
(!fallBack && horizontalSync !== 0.0 ?"
uniform lowp float horizontalSyncStrength;
varying lowp float distortionScale;
varying lowp float distortionFreq;" : "") +
"
void main() {
qt_TexCoord0 = qt_MultiTexCoord0;
vec2 coords = vec2(fract(time/(1024.0*2.0)), fract(time/(1024.0*1024.0)));" +
(!fallBack && (flickering !== 0.0 || horizontalSync !== 0.0) ?
"vec4 initialNoiseTexel = texture2D(noiseSource, coords);"
: "") +
(!fallBack && flickering !== 0.0 ? "
brightness = 1.0 + (initialNoiseTexel.g - 0.5) * flickering;"
: "") +
(!fallBack && horizontalSync !== 0.0 ? "
float randval = horizontalSyncStrength - initialNoiseTexel.r;
distortionScale = step(0.0, randval) * randval * horizontalSyncStrength;
distortionFreq = mix(4.0, 40.0, initialNoiseTexel.g);"
: "") +
"gl_Position = qt_Matrix * qt_Vertex;
}"
fragmentShader: "
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D screenBuffer;
uniform highp float qt_Opacity;
uniform highp float time;
varying highp vec2 qt_TexCoord0;
uniform highp vec4 fontColor;
uniform highp vec4 backgroundColor;
uniform lowp float shadowLength;
uniform highp vec2 virtualResolution;
uniform lowp float rasterizationIntensity;\n" +
(burnIn !== 0 ? "
uniform sampler2D burnInSource;
uniform highp float burnInLastUpdate;
uniform highp float burnInTime;" : "") +
(staticNoise !== 0 ? "
uniform highp float staticNoise;" : "") +
(((staticNoise !== 0 || jitter !== 0) ||(fallBack && (flickering || horizontalSync))) ? "
uniform lowp sampler2D noiseSource;
uniform highp vec2 scaleNoiseSize;" : "") +
(displayTerminalFrame ? "
uniform lowp sampler2D frameSource;" : "") +
(screenCurvature !== 0 ? "
uniform highp float screenCurvature;" : "") +
(glowingLine !== 0 ? "
uniform highp float glowingLine;" : "") +
(chromaColor !== 0 ? "
uniform lowp float chromaColor;" : "") +
(jitter !== 0 ? "
uniform lowp vec2 jitterDisplacement;" : "") +
(ambientLight !== 0 ? "
uniform lowp float ambientLight;" : "") +
(fallBack && horizontalSync !== 0 ? "
uniform lowp float horizontalSyncStrength;" : "") +
(fallBack && flickering !== 0.0 ?"
uniform lowp float flickering;" : "") +
(!fallBack && flickering !== 0 ? "
varying lowp float brightness;"
: "") +
(!fallBack && horizontalSync !== 0 ? "
varying lowp float distortionScale;
varying lowp float distortionFreq;" : "") +
(glowingLine !== 0 ? "
float randomPass(vec2 coords){
return fract(smoothstep(-120.0, 0.0, coords.y - (virtualResolution.y + 120.0) * fract(time * 0.00015)));
}" : "") +
shaderLibrary.min2 +
shaderLibrary.rgb2grey +
shaderLibrary.rasterizationShader +
"
float isInScreen(vec2 v) {
return min2(step(0.0, v) - step(1.0, v));
}
vec2 barrel(vec2 v, vec2 cc) {" +
(screenCurvature !== 0 ? "
float distortion = dot(cc, cc) * screenCurvature;
return (v - cc * (1.0 + distortion) * distortion);"
:
"return v;") +
"}" +
"vec3 convertWithChroma(vec3 inColor) {
vec3 outColor = inColor;" +
(chromaColor !== 0 ?
"outColor = fontColor.rgb * mix(vec3(rgb2grey(inColor)), inColor, chromaColor);"
:
"outColor = fontColor.rgb * rgb2grey(inColor);") +
" return outColor;
}" +
"void main() {" +
"vec2 cc = vec2(0.5) - qt_TexCoord0;" +
"float distance = length(cc);" +
//FallBack if there are problems
(fallBack && (flickering !== 0.0 || horizontalSync !== 0.0) ?
"vec2 initialCoords = vec2(fract(time/(1024.0*2.0)), fract(time/(1024.0*1024.0)));
vec4 initialNoiseTexel = texture2D(noiseSource, initialCoords);"
: "") +
(fallBack && flickering !== 0.0 ? "
float brightness = 1.0 + (initialNoiseTexel.g - 0.5) * flickering;"
: "") +
(fallBack && horizontalSync !== 0.0 ? "
float randval = horizontalSyncStrength - initialNoiseTexel.r;
float distortionScale = step(0.0, randval) * randval * horizontalSyncStrength;
float distortionFreq = mix(4.0, 40.0, initialNoiseTexel.g);"
: "") +
(staticNoise ? "
float noise = staticNoise;" : "") +
(screenCurvature !== 0 ? "
vec2 staticCoords = barrel(qt_TexCoord0, cc);"
:"
vec2 staticCoords = qt_TexCoord0;") +
"vec2 coords = qt_TexCoord0;" +
(horizontalSync !== 0 ? "
float dst = sin((coords.y + time * 0.001) * distortionFreq);
coords.x += dst * distortionScale;" +
(staticNoise ? "
noise += distortionScale * 7.0;" : "")
: "") +
(jitter !== 0 || staticNoise !== 0 ?
"vec4 noiseTexel = texture2D(noiseSource, scaleNoiseSize * coords + vec2(fract(time / 51.0), fract(time / 237.0)));"
: "") +
(jitter !== 0 ? "
vec2 offset = vec2(noiseTexel.b, noiseTexel.a) - vec2(0.5);
vec2 txt_coords = coords + offset * jitterDisplacement;"
: "vec2 txt_coords = coords;") +
"float color = 0.0001;" +
(staticNoise !== 0 ? "
float noiseVal = noiseTexel.a;
color += noiseVal * noise * (1.0 - distance * 1.3);" : "") +
(glowingLine !== 0 ? "
color += randomPass(coords * virtualResolution) * glowingLine;" : "") +
"vec3 txt_color = texture2D(screenBuffer, txt_coords).rgb;" +
(burnIn !== 0 ? "
vec4 txt_blur = texture2D(burnInSource, staticCoords);
float blurDecay = clamp((time - burnInLastUpdate) * burnInTime, 0.0, 1.0);
vec3 burnInColor = 0.65 * (txt_blur.rgb - vec3(blurDecay));
txt_color = max(txt_color, convertWithChroma(burnInColor));"
: "") +
"txt_color += fontColor.rgb * vec3(color);" +
"txt_color = applyRasterization(staticCoords, txt_color, virtualResolution, rasterizationIntensity);\n" +
"vec3 finalColor = txt_color;" +
(flickering !== 0 ? "
finalColor *= brightness;" : "") +
(ambientLight !== 0 ? "
finalColor += vec3(ambientLight) * (1.0 - distance) * (1.0 - distance);" : "") +
(displayTerminalFrame ?
"vec4 frameColor = texture2D(frameSource, qt_TexCoord0);
finalColor = mix(finalColor, frameColor.rgb, frameColor.a);"
: "") +
"gl_FragColor = vec4(finalColor, qt_Opacity);" +
"}"
onStatusChanged: {
// Print warning messages
if (log)
console.log(log);
// Activate fallback mode
if (status == ShaderEffect.Error) {
fallBack = true;
}
}
onStatusChanged: if (log) console.log(log)
}
Loader {
@@ -377,13 +159,13 @@ Item {
property color fontColor: parent.fontColor
property color backgroundColor: parent.backgroundColor
property real bloom: appSettings.bloom * 2.5
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 // TODO FILIPPO width here is wrong.
property real rbgShift: (appSettings.rbgShift / width) * appSettings.totalFontScaling
property int rasterization: appSettings.rasterization
@@ -393,115 +175,37 @@ Item {
property size virtualResolution: parent.virtualResolution
// 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 screenShadowCoeff: 0
property real frameShadowCoeff: 0
property color frameColor: backgroundColor
property size margin: Qt.size(0, 0)
property real prevLastUpdate: burnInEffect.prevLastUpdate
blending: false
visible: false
//Print the number with a reasonable precision for the shader.
function str(num){
return num.toFixed(8);
}
vertexShader: "qrc:/shaders/passthrough.vert.qsb"
fragmentShader: "qrc:/shaders/terminal_static.frag.qsb"
fragmentShader: "
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D source;
uniform highp float qt_Opacity;
varying highp vec2 qt_TexCoord0;
uniform highp vec4 fontColor;
uniform highp vec4 backgroundColor;
uniform lowp float screen_brightness;
uniform highp vec2 virtualResolution;" +
(bloom !== 0 ? "
uniform highp sampler2D bloomSource;
uniform lowp float bloom;" : "") +
(screenCurvature !== 0 ? "
uniform highp float screenCurvature;" : "") +
(chromaColor !== 0 ? "
uniform lowp float chromaColor;" : "") +
(rbgShift !== 0 ? "
uniform lowp float rbgShift;" : "") +
(ambientLight !== 0 ? "
uniform lowp float ambientLight;" : "") +
shaderLibrary.min2 +
shaderLibrary.sum2 +
shaderLibrary.rgb2grey +
"vec3 convertWithChroma(vec3 inColor) {
vec3 outColor = inColor;" +
(chromaColor !== 0 ?
"outColor = fontColor.rgb * mix(vec3(rgb2grey(inColor)), inColor, chromaColor);"
:
"outColor = fontColor.rgb * rgb2grey(inColor);") +
" return outColor;
}" +
shaderLibrary.rasterizationShader +
"void main() {" +
"vec2 cc = vec2(0.5) - qt_TexCoord0;" +
(screenCurvature !== 0 ? "
float distortion = dot(cc, cc) * screenCurvature;
vec2 curvatureCoords = (qt_TexCoord0 - cc * (1.0 + distortion) * distortion);
vec2 txt_coords = - 2.0 * curvatureCoords + 3.0 * step(vec2(0.0), curvatureCoords) * curvatureCoords - 3.0 * step(vec2(1.0), curvatureCoords) * curvatureCoords;"
:"
vec2 txt_coords = qt_TexCoord0;") +
"vec3 txt_color = texture2D(source, txt_coords).rgb;" +
(rbgShift !== 0 ? "
vec2 displacement = vec2(12.0, 0.0) * rbgShift;
vec3 rightColor = texture2D(source, txt_coords + displacement).rgb;
vec3 leftColor = texture2D(source, txt_coords - displacement).rgb;
txt_color.r = leftColor.r * 0.10 + rightColor.r * 0.30 + txt_color.r * 0.60;
txt_color.g = leftColor.g * 0.20 + rightColor.g * 0.20 + txt_color.g * 0.60;
txt_color.b = leftColor.b * 0.30 + rightColor.b * 0.10 + txt_color.b * 0.60;
" : "") +
"txt_color += vec3(0.0001);" +
"float greyscale_color = rgb2grey(txt_color);" +
(screenCurvature !== 0 ? "
float reflectionMask = sum2(step(vec2(0.0), curvatureCoords) - step(vec2(1.0), curvatureCoords));
reflectionMask = clamp(reflectionMask, 0.0, 1.0);"
:
"float reflectionMask = 1.0;") +
(chromaColor !== 0 ?
"vec3 foregroundColor = mix(fontColor.rgb, txt_color * fontColor.rgb / greyscale_color, chromaColor);
vec3 finalColor = mix(backgroundColor.rgb, foregroundColor, greyscale_color * reflectionMask);"
:
"vec3 finalColor = mix(backgroundColor.rgb, fontColor.rgb, greyscale_color * reflectionMask);") +
(bloom !== 0 ?
"vec4 bloomFullColor = texture2D(bloomSource, txt_coords);
vec3 bloomColor = bloomFullColor.rgb;
float bloomAlpha = bloomFullColor.a;
bloomColor = convertWithChroma(bloomColor);
finalColor += clamp(bloomColor * bloom * bloomAlpha, 0.0, 0.5);"
: "") +
"finalColor *= screen_brightness;" +
"gl_FragColor = vec4(finalColor, qt_Opacity);" +
"}"
onStatusChanged: {
// Print warning messages
if (log) console.log(log);
}
onStatusChanged: if (log) console.log(log)
}
ShaderEffectSource {

View File

@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
import QtQuick 2.2
import QtGraphicalEffects 1.0
import Qt5Compat.GraphicalEffects
import "utils.js" as Utils
@@ -38,6 +38,7 @@ ShaderTerminal {
terminalWindow.width * devicePixelRatio * appSettings.windowScaling,
terminalWindow.height * devicePixelRatio * appSettings.windowScaling
)
bloomSource: bloomSourceLoader.item
TimeManager {
id: timeManager
@@ -75,6 +76,4 @@ ShaderTerminal {
visible: false
}
}
bloomSource: bloomSourceLoader.item
}

View File

@@ -40,65 +40,36 @@ ShaderEffect {
appSettings.frameMargin / height * appSettings.windowScaling
)
ShaderLibrary {
id: shaderLibrary
}
// Uniforms required by the shared block
property real qt_Opacity: 1.0
property real time: timeManager.time
property color fontColor: appSettings.fontColor
property color backgroundColor: appSettings.backgroundColor
property real shadowLength: 0
property size virtualResolution: Qt.size(width, height)
property real rasterizationIntensity: 0
property int rasterizationMode: 0
property real burnInLastUpdate: 0
property real burnInTime: 0
property real burnIn: 0
property real staticNoise: 0
property real glowingLine: 0
property real chromaColor: 0
property size jitterDisplacement: Qt.size(0, 0)
property real ambientLight: _ambientLight
property real jitter: 0
property real horizontalSync: 0
property real horizontalSyncStrength: 0
property real flickering: 0
property real displayTerminalFrame: 0
property size scaleNoiseSize: Qt.size(0, 0)
property real screen_brightness: 1.0
property real bloom: 0
property real rbgShift: 0
property real prevLastUpdate: 0
fragmentShader: "
#ifdef GL_ES
precision mediump float;
#endif
uniform lowp float screenCurvature;
uniform lowp float screenShadowCoeff;
uniform lowp float frameShadowCoeff;
uniform highp float qt_Opacity;
uniform lowp vec4 frameColor;
uniform mediump vec2 margin;
varying highp vec2 qt_TexCoord0;
vec2 distortCoordinates(vec2 coords){
vec2 cc = (coords - vec2(0.5));
float dist = dot(cc, cc) * screenCurvature;
return (coords + cc * (1.0 + dist) * dist);
}
" +
shaderLibrary.max2 +
shaderLibrary.min2 +
shaderLibrary.prod2 +
shaderLibrary.sum2 +
"
vec2 positiveLog(vec2 x) {
return clamp(log(x), vec2(0.0), vec2(100.0));
}
void main() {
vec2 staticCoords = qt_TexCoord0;
vec2 coords = distortCoordinates(staticCoords) * (vec2(1.0) + margin * 2.0) - margin;
vec2 vignetteCoords = staticCoords * (1.0 - staticCoords.yx);
float vignette = pow(prod2(vignetteCoords) * 15.0, 0.25);
vec3 color = frameColor.rgb * vec3(1.0 - vignette);
float alpha = 0.0;
float frameShadow = max2(positiveLog(-coords * frameShadowCoeff + vec2(1.0)) + positiveLog(coords * frameShadowCoeff - (vec2(frameShadowCoeff) - vec2(1.0))));
frameShadow = max(sqrt(frameShadow), 0.0);
color *= frameShadow;
alpha = sum2(1.0 - step(vec2(0.0), coords) + step(vec2(1.0), coords));
alpha = clamp(alpha, 0.0, 1.0);
alpha *= mix(1.0, 0.9, frameShadow);
float screenShadow = 1.0 - prod2(positiveLog(coords * screenShadowCoeff + vec2(1.0)) * positiveLog(-coords * screenShadowCoeff + vec2(screenShadowCoeff + 1.0)));
alpha = max(0.8 * screenShadow, alpha);
gl_FragColor = vec4(color * alpha, alpha);
}
"
vertexShader: "qrc:/shaders/passthrough.vert.qsb"
fragmentShader: "qrc:/shaders/terminal_frame.frag.qsb"
onStatusChanged: if (log) console.log(log) //Print warning messages
}

View File

@@ -17,22 +17,29 @@
* 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 QtQuick
Timer {
default property bool enableTimer: false
property real time
QtObject {
id: timeManager
NumberAnimation on time {
from: 0
to: 100000
running: appSettings.fps === 0 && enableTimer
duration: 100000
loops: Animation.Infinite
property bool enableTimer: false
property real time: 0
property int framesPerUpdate: Math.max(1, appSettings.effectsFrameSkip)
property int _frameCounter: 0
property var frameDriver: FrameAnimation {
running: enableTimer
onTriggered: {
timeManager._frameCounter += 1
if (timeManager._frameCounter >= timeManager.framesPerUpdate) {
time = elapsedTime
timeManager._frameCounter = 0
}
}
}
onTriggered: time += interval
running: appSettings.fps !== 0 && enableTimer
interval: Math.round(1000 / appSettings.fps)
repeat: true
onEnableTimerChanged: if (!enableTimer) _frameCounter = 0
onFramesPerUpdateChanged: _frameCounter = 0
}

View File

@@ -82,8 +82,8 @@ Menu {
appSettings.handleFontChanged()
}
}
onObjectAdded: profilesMenu.insertItem(index, object)
onObjectRemoved: profilesMenu.removeItem(object)
onObjectAdded: function(index, object) { profilesMenu.insertItem(index, object) }
onObjectRemoved: function(object) { profilesMenu.removeItem(object) }
}
}
Menu {

View File

@@ -75,8 +75,8 @@ MenuBar {
appSettings.handleFontChanged()
}
}
onObjectAdded: profilesMenu.insertItem(index, object)
onObjectRemoved: profilesMenu.removeItem(object)
onObjectAdded: function(index, object) { profilesMenu.insertItem(index, object) }
onObjectRemoved: function(object) { profilesMenu.removeItem(object) }
}
}
Menu {

View File

@@ -72,8 +72,8 @@ MenuBar {
appSettings.handleFontChanged()
}
}
onObjectAdded: profilesMenu.insertItem(index, object)
onObjectRemoved: profilesMenu.removeItem(object)
onObjectAdded: function(index, object) { profilesMenu.insertItem(index, object) }
onObjectRemoved: function(object) { profilesMenu.removeItem(object) }
}
}
Menu {

View File

@@ -46,5 +46,11 @@
<file>menus/ShortContextMenu.qml</file>
<file>ShaderLibrary.qml</file>
<file>menus/OSXMenu.qml</file>
<file>../shaders/terminal_dynamic.vert.qsb</file>
<file>../shaders/terminal_dynamic.frag.qsb</file>
<file>../shaders/passthrough.vert.qsb</file>
<file>../shaders/terminal_static.frag.qsb</file>
<file>../shaders/terminal_frame.frag.qsb</file>
<file>../shaders/burn_in.frag.qsb</file>
</qresource>
</RCC>

63
app/shaders/burn_in.frag Normal file
View File

@@ -0,0 +1,63 @@
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform ubuf {
mat4 qt_Matrix;
float qt_Opacity;
float time;
vec4 fontColor;
vec4 backgroundColor;
float shadowLength;
vec2 virtualResolution;
float rasterizationIntensity;
int rasterizationMode;
float burnInLastUpdate;
float burnInTime;
float burnIn;
float staticNoise;
float screenCurvature;
float glowingLine;
float chromaColor;
vec2 jitterDisplacement;
float ambientLight;
float jitter;
float horizontalSync;
float horizontalSyncStrength;
float flickering;
float displayTerminalFrame;
vec2 scaleNoiseSize;
float screen_brightness;
float bloom;
float rbgShift;
float screenShadowCoeff;
float frameShadowCoeff;
vec4 frameColor;
vec2 margin;
float prevLastUpdate;
};
layout(binding = 1) uniform sampler2D txt_source;
layout(binding = 2) uniform sampler2D burnInSource;
float rgb2grey(vec3 v) {
return dot(v, vec3(0.21, 0.72, 0.04));
}
void main() {
vec2 coords = qt_TexCoord0;
vec3 txtColor = texture(txt_source, coords).rgb;
vec4 accColor = texture(burnInSource, coords);
float prevMask = accColor.a;
float currMask = rgb2grey(txtColor);
float blurDecay = clamp((burnInLastUpdate - prevLastUpdate) * burnInTime, 0.0, 1.0);
blurDecay = max(0.0, blurDecay - prevMask);
vec3 blurColor = accColor.rgb - vec3(blurDecay);
vec3 color = max(blurColor, txtColor);
fragColor = vec4(color, currMask) * qt_Opacity;
}

Binary file not shown.

View File

@@ -0,0 +1,46 @@
#version 440
layout(location = 0) in vec4 qt_Vertex;
layout(location = 1) in vec2 qt_MultiTexCoord0;
layout(std140, binding = 0) uniform ubuf {
mat4 qt_Matrix;
float qt_Opacity;
float time;
vec4 fontColor;
vec4 backgroundColor;
float shadowLength;
vec2 virtualResolution;
float rasterizationIntensity;
int rasterizationMode;
float burnInLastUpdate;
float burnInTime;
float burnIn;
float staticNoise;
float screenCurvature;
float glowingLine;
float chromaColor;
vec2 jitterDisplacement;
float ambientLight;
float jitter;
float horizontalSync;
float horizontalSyncStrength;
float flickering;
float displayTerminalFrame;
vec2 scaleNoiseSize;
float screen_brightness;
float bloom;
float rbgShift;
float screenShadowCoeff;
float frameShadowCoeff;
vec4 frameColor;
vec2 margin;
float prevLastUpdate;
};
layout(location = 0) out vec2 qt_TexCoord0;
void main() {
qt_TexCoord0 = qt_MultiTexCoord0;
gl_Position = qt_Matrix * qt_Vertex;
}

Binary file not shown.

View File

@@ -0,0 +1,163 @@
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 1) in float vBrightness;
layout(location = 2) in float vDistortionScale;
layout(location = 3) in float vDistortionFreq;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform ubuf {
mat4 qt_Matrix;
float qt_Opacity;
float time;
vec4 fontColor;
vec4 backgroundColor;
float shadowLength;
vec2 virtualResolution;
float rasterizationIntensity;
int rasterizationMode;
float burnInLastUpdate;
float burnInTime;
float burnIn;
float staticNoise;
float screenCurvature;
float glowingLine;
float chromaColor;
vec2 jitterDisplacement;
float ambientLight;
float jitter;
float horizontalSync;
float horizontalSyncStrength;
float flickering;
float displayTerminalFrame;
vec2 scaleNoiseSize;
float screen_brightness;
float bloom;
float rbgShift;
float screenShadowCoeff;
float frameShadowCoeff;
vec4 frameColor;
vec2 margin;
float prevLastUpdate;
};
layout(binding = 0) uniform sampler2D noiseSource;
layout(binding = 1) uniform sampler2D screenBuffer;
layout(binding = 2) uniform sampler2D burnInSource;
layout(binding = 3) uniform sampler2D frameSource;
float min2(vec2 v) { return min(v.x, v.y); }
float prod2(vec2 v) { return v.x * v.y; }
float sum2(vec2 v) { return v.x + v.y; }
float rgb2grey(vec3 v) { return dot(v, vec3(0.21, 0.72, 0.04)); }
vec3 applyRasterization(vec2 screenCoords, vec3 texel, vec2 virtualRes, float intensity, int mode) {
if (intensity <= 0.0 || mode == 0) {
return texel;
}
const float INTENSITY = 0.30;
const float BRIGHTBOOST = 0.30;
if (mode == 1) { // scanline
vec3 pixelHigh = ((1.0 + BRIGHTBOOST) - (0.2 * texel)) * texel;
vec3 pixelLow = ((1.0 - INTENSITY) + (0.1 * texel)) * texel;
vec2 coords = fract(screenCoords * virtualRes) * 2.0 - vec2(1.0);
float mask = 1.0 - abs(coords.y);
vec3 rasterizationColor = mix(pixelLow, pixelHigh, mask);
return mix(texel, rasterizationColor, intensity);
} else if (mode == 2) { // pixel
vec3 pixelHigh = ((1.0 + BRIGHTBOOST) - (0.2 * texel)) * texel;
vec3 pixelLow = ((1.0 - INTENSITY) + (0.1 * texel)) * texel;
vec2 coords = fract(screenCoords * virtualRes) * 2.0 - vec2(1.0);
coords = coords * coords;
float mask = 1.0 - coords.x - coords.y;
vec3 rasterizationColor = mix(pixelLow, pixelHigh, mask);
return mix(texel, rasterizationColor, intensity);
} else if (mode == 3) { // subpixel
const float SUBPIXELS = 3.0;
vec3 offsets = vec3(3.141592654) * vec3(0.5, 0.5 - 2.0 / 3.0, 0.5 - 4.0 / 3.0);
vec2 omega = vec2(3.141592654) * vec2(2.0) * virtualRes;
vec2 angle = screenCoords * omega;
vec3 xfactors = (SUBPIXELS + sin(angle.x + offsets)) / (SUBPIXELS + 1.0);
vec3 result = texel * xfactors;
vec3 pixelHigh = ((1.0 + BRIGHTBOOST) - (0.2 * result)) * result;
vec3 pixelLow = ((1.0 - INTENSITY) + (0.1 * result)) * result;
vec2 coords = fract(screenCoords * virtualRes) * 2.0 - vec2(1.0);
float mask = 1.0 - abs(coords.y);
vec3 rasterizationColor = mix(pixelLow, pixelHigh, mask);
return mix(texel, rasterizationColor, intensity);
}
return texel;
}
float randomPass(vec2 coords){
return fract(smoothstep(-120.0, 0.0, coords.y - (virtualResolution.y + 120.0) * fract(time * 0.15)));
}
vec2 barrel(vec2 v, vec2 cc) {
float distortion = dot(cc, cc) * screenCurvature;
return (v - cc * (1.0 + distortion) * distortion);
}
vec3 convertWithChroma(vec3 inColor) {
vec3 outColor = fontColor.rgb * rgb2grey(inColor);
if (chromaColor != 0.0) {
outColor = fontColor.rgb * mix(vec3(rgb2grey(inColor)), inColor, chromaColor);
}
return outColor;
}
void main() {
vec2 cc = vec2(0.5) - qt_TexCoord0;
float distance = length(cc);
vec2 staticCoords = barrel(qt_TexCoord0, cc);
vec2 coords = qt_TexCoord0;
float dst = sin((coords.y + time) * vDistortionFreq);
coords.x += dst * vDistortionScale;
vec4 noiseTexel = texture(noiseSource, scaleNoiseSize * coords + vec2(fract(time / 0.051), fract(time / 0.237)));
vec2 txt_coords = coords + (noiseTexel.ba - vec2(0.5)) * jitterDisplacement * jitter;
float color = 0.0001;
color += noiseTexel.a * staticNoise * (1.0 - distance * 1.3);
color += randomPass(coords * virtualResolution) * glowingLine;
vec3 txt_color = texture(screenBuffer, txt_coords).rgb;
if (burnIn > 0.0) {
vec4 txt_blur = texture(burnInSource, staticCoords);
float blurDecay = clamp((time - burnInLastUpdate) * burnInTime, 0.0, 1.0);
vec3 burnInColor = 0.65 * (txt_blur.rgb - vec3(blurDecay));
txt_color = max(txt_color, convertWithChroma(burnInColor));
}
txt_color += fontColor.rgb * vec3(color);
txt_color = applyRasterization(staticCoords, txt_color, virtualResolution, rasterizationIntensity, rasterizationMode);
vec3 finalColor = txt_color;
float brightness = mix(1.0, vBrightness, step(0.0, flickering));
finalColor *= brightness;
finalColor += vec3(ambientLight) * (1.0 - distance) * (1.0 - distance);
if (displayTerminalFrame > 0.0) {
vec4 frameColor = texture(frameSource, qt_TexCoord0);
finalColor = mix(finalColor, frameColor.rgb, frameColor.a);
}
fragColor = vec4(finalColor, qt_Opacity);
}

Binary file not shown.

View File

@@ -0,0 +1,61 @@
#version 440
layout(location = 0) in vec4 qt_Vertex;
layout(location = 1) in vec2 qt_MultiTexCoord0;
layout(std140, binding = 0) uniform ubuf {
mat4 qt_Matrix;
float qt_Opacity;
float time;
vec4 fontColor;
vec4 backgroundColor;
float shadowLength;
vec2 virtualResolution;
float rasterizationIntensity;
int rasterizationMode;
float burnInLastUpdate;
float burnInTime;
float burnIn;
float staticNoise;
float screenCurvature;
float glowingLine;
float chromaColor;
vec2 jitterDisplacement;
float ambientLight;
float jitter;
float horizontalSync;
float horizontalSyncStrength;
float flickering;
float displayTerminalFrame;
vec2 scaleNoiseSize;
float screen_brightness;
float bloom;
float rbgShift;
float screenShadowCoeff;
float frameShadowCoeff;
vec4 frameColor;
vec2 margin;
float prevLastUpdate;
};
layout(binding = 0) uniform sampler2D noiseSource;
layout(location = 0) out vec2 qt_TexCoord0;
layout(location = 1) out float vBrightness;
layout(location = 2) out float vDistortionScale;
layout(location = 3) out float vDistortionFreq;
void main() {
qt_TexCoord0 = qt_MultiTexCoord0;
vec2 coords = vec2(fract(time / 2.048), fract(time / 1048.576));
vec4 initialNoiseTexel = texture(noiseSource, coords);
vBrightness = 1.0 + (initialNoiseTexel.g - 0.5) * flickering;
float randval = horizontalSyncStrength - initialNoiseTexel.r;
vDistortionScale = step(0.0, randval) * randval * horizontalSyncStrength * horizontalSync;
vDistortionFreq = mix(4.0, 40.0, initialNoiseTexel.g) * step(0.0, horizontalSync);
gl_Position = qt_Matrix * qt_Vertex;
}

Binary file not shown.

View File

@@ -0,0 +1,77 @@
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform ubuf {
mat4 qt_Matrix;
float qt_Opacity;
float time;
vec4 fontColor;
vec4 backgroundColor;
float shadowLength;
vec2 virtualResolution;
float rasterizationIntensity;
int rasterizationMode;
float burnInLastUpdate;
float burnInTime;
float burnIn;
float staticNoise;
float screenCurvature;
float glowingLine;
float chromaColor;
vec2 jitterDisplacement;
float ambientLight;
float jitter;
float horizontalSync;
float horizontalSyncStrength;
float flickering;
float displayTerminalFrame;
vec2 scaleNoiseSize;
float screen_brightness;
float bloom;
float rbgShift;
float screenShadowCoeff;
float frameShadowCoeff;
vec4 frameColor;
vec2 margin;
float prevLastUpdate;
};
float min2(vec2 v) { return min(v.x, v.y); }
float max2(vec2 v) { return max(v.x, v.y); }
float prod2(vec2 v) { return v.x * v.y; }
float sum2(vec2 v) { return v.x + v.y; }
vec2 distortCoordinates(vec2 coords){
vec2 cc = (coords - vec2(0.5));
float dist = dot(cc, cc) * screenCurvature;
return (coords + cc * (1.0 + dist) * dist);
}
vec2 positiveLog(vec2 x) {
return clamp(log(x), vec2(0.0), vec2(100.0));
}
void main() {
vec2 staticCoords = qt_TexCoord0;
vec2 coords = distortCoordinates(staticCoords) * (vec2(1.0) + margin * 2.0) - margin;
vec2 vignetteCoords = staticCoords * (1.0 - staticCoords.yx);
float vignette = pow(prod2(vignetteCoords) * 15.0, 0.25);
vec3 color = frameColor.rgb * vec3(1.0 - vignette);
float alpha = 0.0;
float frameShadow = max2(positiveLog(-coords * frameShadowCoeff + vec2(1.0)) + positiveLog(coords * frameShadowCoeff - (vec2(frameShadowCoeff) - vec2(1.0))));
frameShadow = max(sqrt(frameShadow), 0.0);
color *= frameShadow;
alpha = sum2(1.0 - step(vec2(0.0), coords) + step(vec2(1.0), coords));
alpha = clamp(alpha, 0.0, 1.0);
alpha *= mix(1.0, 0.9, frameShadow);
float screenShadow = 1.0 - prod2(positiveLog(coords * screenShadowCoeff + vec2(1.0)) * positiveLog(-coords * screenShadowCoeff + vec2(screenShadowCoeff + 1.0)));
alpha = max(0.8 * screenShadow, alpha);
fragColor = vec4(color * alpha, alpha) * qt_Opacity;
}

Binary file not shown.

View File

@@ -0,0 +1,104 @@
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform ubuf {
mat4 qt_Matrix;
float qt_Opacity;
float time;
vec4 fontColor;
vec4 backgroundColor;
float shadowLength;
vec2 virtualResolution;
float rasterizationIntensity;
int rasterizationMode;
float burnInLastUpdate;
float burnInTime;
float burnIn;
float staticNoise;
float screenCurvature;
float glowingLine;
float chromaColor;
vec2 jitterDisplacement;
float ambientLight;
float jitter;
float horizontalSync;
float horizontalSyncStrength;
float flickering;
float displayTerminalFrame;
vec2 scaleNoiseSize;
float screen_brightness;
float bloom;
float rbgShift;
float screenShadowCoeff;
float frameShadowCoeff;
vec4 frameColor;
vec2 margin;
float prevLastUpdate;
};
layout(binding = 1) uniform sampler2D source;
layout(binding = 2) uniform sampler2D bloomSource;
float sum2(vec2 v) { return v.x + v.y; }
float rgb2grey(vec3 v) { return dot(v, vec3(0.21, 0.72, 0.04)); }
vec3 convertWithChroma(vec3 inColor) {
vec3 outColor = fontColor.rgb * rgb2grey(inColor);
if (chromaColor != 0.0) {
outColor = fontColor.rgb * mix(vec3(rgb2grey(inColor)), inColor, chromaColor);
}
return outColor;
}
void main() {
vec2 cc = vec2(0.5) - qt_TexCoord0;
vec2 txt_coords = qt_TexCoord0;
if (screenCurvature != 0.0) {
float distortion = dot(cc, cc) * screenCurvature;
vec2 curvatureCoords = (qt_TexCoord0 - cc * (1.0 + distortion) * distortion);
txt_coords = -2.0 * curvatureCoords + 3.0 * step(vec2(0.0), curvatureCoords) * curvatureCoords - 3.0 * step(vec2(1.0), curvatureCoords) * curvatureCoords;
}
vec3 txt_color = texture(source, txt_coords).rgb;
if (rbgShift != 0.0) {
vec2 displacement = vec2(12.0, 0.0) * rbgShift;
vec3 rightColor = texture(source, txt_coords + displacement).rgb;
vec3 leftColor = texture(source, txt_coords - displacement).rgb;
txt_color.r = leftColor.r * 0.10 + rightColor.r * 0.30 + txt_color.r * 0.60;
txt_color.g = leftColor.g * 0.20 + rightColor.g * 0.20 + txt_color.g * 0.60;
txt_color.b = leftColor.b * 0.30 + rightColor.b * 0.10 + txt_color.b * 0.60;
}
txt_color += vec3(0.0001);
float greyscale_color = rgb2grey(txt_color);
float reflectionMask = 1.0;
if (screenCurvature != 0.0) {
float distortion = dot(cc, cc) * screenCurvature;
vec2 curvatureCoords = (qt_TexCoord0 - cc * (1.0 + distortion) * distortion);
reflectionMask = sum2(step(vec2(0.0), curvatureCoords) - step(vec2(1.0), curvatureCoords));
reflectionMask = clamp(reflectionMask, 0.0, 1.0);
}
vec3 finalColor;
if (chromaColor != 0.0) {
vec3 foregroundColor = mix(fontColor.rgb, txt_color * fontColor.rgb / greyscale_color, chromaColor);
finalColor = mix(backgroundColor.rgb, foregroundColor, greyscale_color * reflectionMask);
} else {
finalColor = mix(backgroundColor.rgb, fontColor.rgb, greyscale_color * reflectionMask);
}
if (bloom != 0.0) {
vec4 bloomFullColor = texture(bloomSource, txt_coords);
vec3 bloomColor = convertWithChroma(bloomFullColor.rgb);
float bloomAlpha = bloomFullColor.a;
finalColor += clamp(bloomColor * bloom * bloomAlpha, 0.0, 0.5);
}
finalColor *= screen_brightness;
fragColor = vec4(finalColor, qt_Opacity);
}

Binary file not shown.