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

20 Commits

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
Filippo Scognamiglio
74ae511f92 Bump version. Yeeee 2022-01-29 15:15:52 +01:00
Filippo Scognamiglio
a3fbafe4ae Update README.md 2022-01-29 15:10:08 +01:00
Filippo Scognamiglio
8a45fbe9ed Tweak settings window and label sizes. 2022-01-16 09:40:20 +01:00
Filippo Scognamiglio
01c7929ee3 Increase size of settings window. 2022-01-12 21:11:58 +01:00
Filippo Scognamiglio
2261af17d7 Restore legacy Connection slots. Restore compilation on Qt 5.12. 2022-01-12 21:08:58 +01:00
Filippo Scognamiglio
41f34c3992 Disable Fusion style which has issues with dark themes. 2022-01-12 21:00:11 +01:00
Filippo Scognamiglio
36b1cd2dde Add github funding links. 2022-01-09 15:11:08 +01:00
Filippo Scognamiglio
80374b3ec6 Update README.md 2022-01-09 15:08:15 +01:00
Filippo Scognamiglio
bc00d1e45f Bump version. 2022-01-09 14:08:36 +01:00
Filippo Scognamiglio
6ddb507247 Merge pull request #694 from Swordfish90/osx-fixes
MacOS improvements
2022-01-09 10:56:30 +01:00
37 changed files with 1008 additions and 893 deletions

4
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,4 @@
# These are supported funding model platforms
patreon: swordfish90
custom: ['https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=flscogna%40gmail.com&item_name=Support+CRT&currency_code=EUR&source=url']

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

197
README.md
View File

@@ -8,9 +8,9 @@
cool-retro-term is a terminal emulator which mimics the look and feel of the old cathode tube screens.
It has been designed to be eye-candy, customizable, and reasonably lightweight.
It uses the QML port of qtermwidget (Konsole) developed by me: https://github.com/Swordfish90/qmltermwidget.
It uses the QML port of qtermwidget (Konsole): https://github.com/Swordfish90/qmltermwidget.
This terminal emulator works under Linux and macOS and requires Qt 5.2 or higher.
This terminal emulator works under Linux and macOS and requires Qt5. It's suggested that you stick to the latest LTS version.
Settings such as colors, fonts, and effects can be accessed via context menu.
@@ -20,196 +20,11 @@ Settings such as colors, fonts, and effects can be accessed via context menu.
![Image](<https://i.imgur.com/GYRDPzJ.jpg>)
## Install
Walk the easy way and install cool-retro-term using one of these convenient packages:
Just grab the latest AppImage from the release page and make it executable and run it:
If you want to get a hold of the latest version, just go to the Releases page and grab the latest AppImage (Linux) or dmg (macOS).
wget https://github.com/Swordfish90/cool-retro-term/releases/download/1.1.1/Cool-Retro-Term-1.1.1-x86_64.AppImage
chmod a+x Cool-Retro-Term-1.1.1-x86_64.AppImage
./Cool-Retro-Term-1.1.1-x86_64.AppImage
Alternatively, most distributions such as Ubuntu, Fedora or Arch already package cool-retro-term in their official repositories.
**Fedora** has the `cool-retro-term` in the official repositories. All you have to do is `sudo dnf install cool-retro-term`.
## Building
Users of **openSUSE** can grab a package from [Open Build Service](http://software.opensuse.org/package/cool-retro-term).
**Arch** users can install this [package](https://aur.archlinux.org/packages/cool-retro-term-git/) directly via the [AUR](https://aur.archlinux.org):
trizen -S aur/cool-retro-term-git
or use:
pacman -S cool-retro-term
to install precompiled from community repository.
Users of **Ubuntu 14.04 LTS (Trusty) up to 15.10 (Wily)** can use [this PPA](https://launchpad.net/~bugs-launchpad-net-falkensweb).
**Ubuntu 17.10** can use [this PPA](https://launchpad.net/%7Evantuz/+archive/ubuntu/cool-retro-term)
**Solus** users can install using `eopg`:
```
eopkg it cool-retro-term
```
**macOS** users can grab the latest dmg from the [release page](https://github.com/Swordfish90/cool-retro-term/releases) or install via Homebrew or MacPorts:
```
brew install cool-retro-term --cask
```
or
```
port install cool-retro-term
```
**FreeBSD** users can install cool-retro-term with `pkg`:
pkg install cool-retro-term
## Build instructions (FreeBSD)
Grab a copy of [the FreeBSD Ports Collection](https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html), modify [`/usr/ports/x11/cool-retro-term/Makefile`](https://svnweb.freebsd.org/ports/head/x11/cool-retro-term/Makefile?view=markup) as you like, and then run `make install` to build and install the emulator:
```
cd /usr/ports/x11/cool-retro-term
make install
```
## Build instructions (Linux)
Build cool-retro-term yourself, you know, the retro way.
## Dependencies
Make sure to install these first.
---
**Ubuntu 14.04**
sudo apt-get install build-essential qmlscene qt5-qmake qt5-default qtdeclarative5-dev qtdeclarative5-controls-plugin qtdeclarative5-qtquick2-plugin libqt5qml-graphicaleffects qtdeclarative5-dialogs-plugin qtdeclarative5-localstorage-plugin qtdeclarative5-window-plugin
---
**Ubuntu 16.10**
sudo apt-get install build-essential qmlscene qt5-qmake qt5-default qtdeclarative5-dev qml-module-qtquick-controls qtdeclarative5-qtquick2-plugin libqt5qml-graphicaleffects qml-module-qtquick-dialogs qtdeclarative5-localstorage-plugin qtdeclarative5-window-plugin
---
**Ubuntu 17.04**
sudo apt install build-essential libqt5qml-graphicaleffects qml-module-qt-labs-folderlistmodel qml-module-qt-labs-settings qml-module-qtquick-controls qml-module-qtquick-dialogs qmlscene qt5-default qt5-qmake qtdeclarative5-dev qtdeclarative5-localstorage-plugin qtdeclarative5-qtquick2-plugin qtdeclarative5-window-plugin
---
**Ubuntu 17.10**
sudo apt-get install build-essential qml-module-qtgraphicaleffects qml-module-qt-labs-folderlistmodel qml-module-qt-labs-settings qml-module-qtquick-controls qml-module-qtquick-dialogs qmlscene qt5-default qt5-qmake qtdeclarative5-dev qtdeclarative5-localstorage-plugin qtdeclarative5-qtquick2-plugin qtdeclarative5-window-plugin
---
**snapcraft (most of distros)**
sudo snap install cool-retro-term --classic
---
**Debian Jessie and above**
sudo apt install build-essential qmlscene qt5-qmake qt5-default qtdeclarative5-dev qml-module-qtquick-controls qml-module-qtgraphicaleffects qml-module-qtquick-dialogs qml-module-qtquick-localstorage qml-module-qtquick-window2 qml-module-qt-labs-settings qml-module-qt-labs-folderlistmodel
---
**Fedora**
This command should install the known fedora dependencies:
sudo yum -y install qt5-qtbase qt5-qtbase-devel qt5-qtdeclarative qt5-qtdeclarative-devel qt5-qtgraphicaleffects qt5-qtquickcontrols redhat-rpm-config
or:
sudo dnf -y install qt5-qtbase qt5-qtbase-devel qt5-qtdeclarative qt5-qtdeclarative-devel qt5-qtgraphicaleffects qt5-qtquickcontrols redhat-rpm-config
---
**Arch Linux**
sudo pacman -S qt5-base qt5-declarative qt5-quickcontrols qt5-graphicaleffects
---
**openSUSE**
Add repository with latest Qt 5 (this is only needed on openSUSE 13.1, Factory already has it):
sudo zypper ar http://download.opensuse.org/repositories/KDE:/Qt5/openSUSE_13.1/ KDE:Qt5
Install dependencies:
sudo zypper install libqt5-qtbase-devel libqt5-qtdeclarative-devel libqt5-qtquickcontrols libqt5-qtgraphicaleffects
---
**Anyone else**
Install Qt directly from here http://qt-project.org/downloads . Once done export them in you path (replace "_/opt/Qt5.3.1/5.3/gcc_64/bin_" with your correct folder):
export PATH=/opt/Qt5.3.1/5.3/gcc_64/bin/:$PATH
---
### Compile
Once you installed all dependencies (Qt is installed and in your path) you need to compile and run the application:
```bash
# Get it from GitHub
git clone --recursive https://github.com/Swordfish90/cool-retro-term.git
# Build it
cd cool-retro-term
# Compile (Fedora and OpenSUSE user should use qmake-qt5 instead of qmake)
qmake && make
# Have fun!
./cool-retro-term
```
## Build instructions (macOS)
1. Install [Xcode](https://developer.apple.com/xcode/) and agree to the licence agreement
2. Enter the following commands into the terminal:
**Brew**
```sh
brew install qt5
git clone --recursive https://github.com/Swordfish90/cool-retro-term.git
export CPPFLAGS="-I/usr/local/opt/qt5/include"
export LDFLAGS="-L/usr/local/opt/qt5/lib"
export PATH=/usr/local/opt/qt5/bin:$PATH
cd cool-retro-term
qmake && make
mkdir cool-retro-term.app/Contents/PlugIns
cp -r qmltermwidget/QMLTermWidget cool-retro-term.app/Contents/PlugIns
open cool-retro-term.app
```
**MacPorts**
```sh
sudo port install qt5
git clone --recursive https://github.com/Swordfish90/cool-retro-term.git
cd cool-retro-term
/opt/local/libexec/qt5/bin/qmake && make
mkdir cool-retro-term.app/Contents/PlugIns
cp -r qmltermwidget/QMLTermWidget cool-retro-term.app/Contents/PlugIns
open cool-retro-term.app
```
**Homebrew**
```sh
brew install cool-retro-term --cask
```
## Donations
I made this project in my spare time because I love what I'm doing. If you are enjoying it, and you want to buy me a beer click [here](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=flscogna%40gmail%2ecom&lc=IT&item_name=Filippo%20Scognamiglio&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted).
You can also add "bounties" on your favourite issues. More information on the [Bountysource](https://www.bountysource.com/teams/crt/issues) page.
Check out the wiki and follow the instructions on how to build it on [Linux](https://github.com/Swordfish90/cool-retro-term/wiki/Build-Instructions-(Linux)) and [macOS](https://github.com/Swordfish90/cool-retro-term/wiki/Build-Instructions-(macOS)).

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,45 +35,46 @@ 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);
#endif
// Force fusion style on every platform
QQuickStyle::setStyle("Fusion");
// 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;
}
QString appVersion("1.1.1");
QString appVersion("1.2.0");
if (argc>1 && (!strcmp(argv[1],"-v") || !strcmp(argv[1],"--version"))) {
QTextStream cout(stdout, QIODevice::WriteOnly);
cout << "cool-retro-term " << appVersion << endl;
return 0;
cout << "cool-retro-term " << appVersion << Qt::endl;
return 0;
}
QApplication app(argc, argv);

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

@@ -76,7 +76,7 @@ Loader {
Connections {
target: kterminal
function onImagePainted() {
onImagePainted: {
completelyUpdate()
}
}
@@ -84,76 +84,68 @@ Loader {
Connections {
target: appSettings
function onBurnInChanged() {
onBurnInChanged: {
burnInEffect.restartBlurSource()
}
function onTerminalFontChanged() {
onTerminalFontChanged: {
burnInEffect.restartBlurSource()
}
function onRasterizationChanged() {
onRasterizationChanged: {
burnInEffect.restartBlurSource()
}
function onBurnInQualityChanged() {
onBurnInQualityChanged: {
burnInEffect.restartBlurSource()
}
}
}
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

@@ -47,14 +47,14 @@ Item{
Connections {
target: copyAction
function onTriggered() {
onTriggered: {
kterminal.copyClipboard()
}
}
Connections {
target: pasteAction
function onTriggered() {
onTriggered: {
kterminal.pasteClipboard()
}
}
@@ -63,29 +63,29 @@ Item{
Connections {
target: appSettings
function onFontScalingChanged() {
onFontScalingChanged: {
terminalContainer.updateSources()
}
function onFontWidthChanged() {
onFontWidthChanged: {
terminalContainer.updateSources()
}
}
Connections {
target: terminalContainer
function onWidthChanged() {
onWidthChanged: {
terminalContainer.updateSources()
}
function onHeightChanged() {
onHeightChanged: {
terminalContainer.updateSources()
}
}
Connections {
target: terminalWindow
function onActiveChanged() {
onActiveChanged: {
kterminal.forceActiveFocus()
}
}
@@ -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
}
Label {
text: appSettings.fps !== 0 ? appSettings.fps : qsTr("Max")
SizedLabel {
text: Math.round(100 / Math.max(1, Math.round(effectsFpsSlider.value))) + "%"
}
Label {
text: qsTr("Texture Quality")
@@ -99,17 +92,13 @@ 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
}
Label {
SizedLabel {
text: Math.round(txtslider.value * 100) + "%"
}
@@ -120,17 +109,13 @@ 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
}
Label {
SizedLabel {
text: Math.round(bloomSlider.value * 100) + "%"
}
@@ -141,17 +126,13 @@ 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
}
Label {
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

@@ -69,7 +69,7 @@ ColumnLayout {
Connections {
target: appSettings
function onTerminalFontChanged() {
onTerminalFontChanged: {
fontChanger.updateIndex()
}
}
@@ -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,13 +22,13 @@ 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
title: qsTr("Settings")
width: 600
height: 480
width: 640
height: 640
property int tabmargins: 15

View File

@@ -19,7 +19,6 @@
*******************************************************************************/
import QtQuick 2.2
import QtGraphicalEffects 1.0
import "utils.js" as Utils
@@ -45,469 +44,174 @@ Item {
screenResolution.height / virtualResolution.height
)
ShaderEffect {
id: dynamicShader
property ShaderLibrary shaderLibrary: ShaderLibrary { }
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 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
anchors.fill: parent
blending: false
//Smooth random texture used for flickering effect.
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
}
//Print the number with a reasonable precision for the shader.
function str(num){
return num.toFixed(8);
}
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;") +
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))
"float color = 0.0001;" +
property size virtualResolution: parent.virtualResolution
(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;
}
}
}
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: appSettings.bloom * 2.5
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 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
blending: false
visible: false
//Print the number with a reasonable precision for the shader.
function str(num){
return num.toFixed(8);
}
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);
}
}
ShaderEffectSource {
id: frameBuffer
visible: false
sourceItem: staticShader
hideSource: true
}
// 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
// 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
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
// 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
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
}
}

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.