mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-01-18 12:15:27 +00:00
Burnin is now subtractive. Better looking and more predictable.
This commit is contained in:
parent
17b70b47ce
commit
a24cbbcc93
@ -23,6 +23,8 @@ import QtQuick.Controls 1.1
|
|||||||
|
|
||||||
import QMLTermWidget 1.0
|
import QMLTermWidget 1.0
|
||||||
|
|
||||||
|
import "utils.js" as Utils
|
||||||
|
|
||||||
Item{
|
Item{
|
||||||
id: terminalContainer
|
id: terminalContainer
|
||||||
|
|
||||||
@ -43,10 +45,10 @@ Item{
|
|||||||
anchors.bottomMargin: frame.displacementBottom * appSettings.windowScaling
|
anchors.bottomMargin: frame.displacementBottom * appSettings.windowScaling
|
||||||
|
|
||||||
//The blur effect has to take into account the framerate
|
//The blur effect has to take into account the framerate
|
||||||
property real mBlur: appSettings.burnIn
|
property real mBlur: Math.sqrt(appSettings.burnIn)
|
||||||
property real motionBlurCoefficient: (_maxBlurCoefficient * Math.sqrt(mBlur) + _minBlurCoefficient * (1 - Math.sqrt(mBlur)))
|
property real motionBlurCoefficient: Utils.lint(_minBlurCoefficient, _maxBlurCoefficient, mBlur)
|
||||||
property real _minBlurCoefficient: 0.50
|
property real _minBlurCoefficient: 0.2
|
||||||
property real _maxBlurCoefficient: 0.90
|
property real _maxBlurCoefficient: 0.02
|
||||||
|
|
||||||
property size terminalSize: kterminal.terminalSize
|
property size terminalSize: kterminal.terminalSize
|
||||||
property size fontMetrics: kterminal.fontMetrics
|
property size fontMetrics: kterminal.fontMetrics
|
||||||
@ -244,6 +246,12 @@ Item{
|
|||||||
|
|
||||||
Timer{
|
Timer{
|
||||||
id: livetimer
|
id: livetimer
|
||||||
|
|
||||||
|
// The interval assumes 60 fps. This is the time needed burnout a white pixel.
|
||||||
|
// We multiply 1.1 to have a little bit of margin over the theoretical value.
|
||||||
|
// This solution is not extremely clean, but it's probably the best to avoid measuring fps.
|
||||||
|
|
||||||
|
interval: (1 / motionBlurCoefficient) * 60 * 1.1
|
||||||
running: true
|
running: true
|
||||||
onTriggered: _blurredSourceEffect.live = false;
|
onTriggered: _blurredSourceEffect.live = false;
|
||||||
}
|
}
|
||||||
@ -287,7 +295,7 @@ Item{
|
|||||||
sourceComponent: ShaderEffect {
|
sourceComponent: ShaderEffect {
|
||||||
property variant txt_source: kterminalSource
|
property variant txt_source: kterminalSource
|
||||||
property variant blurredSource: blurredSourceLoader.item
|
property variant blurredSource: blurredSourceLoader.item
|
||||||
property real blurCoefficient: (1.0 - motionBlurCoefficient)
|
property real blurCoefficient: motionBlurCoefficient
|
||||||
|
|
||||||
blending: false
|
blending: false
|
||||||
|
|
||||||
@ -307,10 +315,10 @@ Item{
|
|||||||
"void main() {" +
|
"void main() {" +
|
||||||
"vec2 coords = qt_TexCoord0;" +
|
"vec2 coords = qt_TexCoord0;" +
|
||||||
"vec3 origColor = texture2D(txt_source, coords).rgb;" +
|
"vec3 origColor = texture2D(txt_source, coords).rgb;" +
|
||||||
"vec3 blur_color = texture2D(blurredSource, coords).rgb * (1.0 - blurCoefficient);" +
|
"vec3 blur_color = texture2D(blurredSource, coords).rgb - vec3(blurCoefficient);" +
|
||||||
"vec3 color = min(origColor + blur_color, max(origColor, blur_color));" +
|
"vec3 color = min(origColor + blur_color, max(origColor, blur_color));" +
|
||||||
|
|
||||||
"gl_FragColor = vec4(color, step(0.02, rgb2grey(color - origColor)));" +
|
"gl_FragColor = vec4(color, rgb2grey(color - origColor));" +
|
||||||
"}"
|
"}"
|
||||||
|
|
||||||
onStatusChanged: if (log) console.log(log) //Print warning messages
|
onStatusChanged: if (log) console.log(log) //Print warning messages
|
||||||
|
@ -26,6 +26,8 @@ ShaderEffect {
|
|||||||
property ShaderEffectSource blurredSource
|
property ShaderEffectSource blurredSource
|
||||||
property ShaderEffectSource bloomSource
|
property ShaderEffectSource bloomSource
|
||||||
|
|
||||||
|
property real liveBlur: blurredSource && blurredSource.live ? 1.0 : 0.0
|
||||||
|
|
||||||
property color fontColor: appSettings.fontColor
|
property color fontColor: appSettings.fontColor
|
||||||
property color backgroundColor: appSettings.backgroundColor
|
property color backgroundColor: appSettings.backgroundColor
|
||||||
property real bloom: appSettings.bloom * 2.5
|
property real bloom: appSettings.bloom * 2.5
|
||||||
@ -160,7 +162,8 @@ ShaderEffect {
|
|||||||
uniform highp sampler2D bloomSource;
|
uniform highp sampler2D bloomSource;
|
||||||
uniform lowp float bloom;" : "") +
|
uniform lowp float bloom;" : "") +
|
||||||
(burnIn !== 0 ? "
|
(burnIn !== 0 ? "
|
||||||
uniform sampler2D blurredSource;" : "") +
|
uniform sampler2D blurredSource;
|
||||||
|
uniform lowp float liveBlur;" : "") +
|
||||||
(staticNoise !== 0 ? "
|
(staticNoise !== 0 ? "
|
||||||
uniform highp float staticNoise;" : "") +
|
uniform highp float staticNoise;" : "") +
|
||||||
(((staticNoise !== 0 || jitter !== 0 || rbgShift)
|
(((staticNoise !== 0 || jitter !== 0 || rbgShift)
|
||||||
@ -266,7 +269,7 @@ ShaderEffect {
|
|||||||
"vec3 txt_color = texture2D(source, txt_coords).rgb;" +
|
"vec3 txt_color = texture2D(source, txt_coords).rgb;" +
|
||||||
|
|
||||||
(burnIn !== 0 ? "
|
(burnIn !== 0 ? "
|
||||||
vec4 txt_blur = texture2D(blurredSource, txt_coords);
|
vec4 txt_blur = liveBlur * texture2D(blurredSource, txt_coords);
|
||||||
txt_color = txt_color + txt_blur.rgb * txt_blur.a;"
|
txt_color = txt_color + txt_blur.rgb * txt_blur.a;"
|
||||||
: "") +
|
: "") +
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user