mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-04-19 01:00:47 +01:00
Moved bloom where it belongs, in postprocessing instead of preprocessing. Restored glowing line animation.
This commit is contained in:
parent
a729eae191
commit
8cb9520ea7
@ -19,14 +19,18 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
|
import QtGraphicalEffects 1.0
|
||||||
|
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
property color font_color: shadersettings.font_color
|
property color font_color: shadersettings.font_color
|
||||||
property color background_color: shadersettings.background_color
|
property color background_color: shadersettings.background_color
|
||||||
property variant source: theSource
|
property variant source: theSource
|
||||||
|
property variant bloomSource: bloomSource
|
||||||
property size txt_Size: Qt.size(terminal.width, terminal.height)
|
property size txt_Size: Qt.size(terminal.width, terminal.height)
|
||||||
property real time: 0
|
property real time: 0
|
||||||
|
|
||||||
|
property real bloom: shadersettings.bloom_strength
|
||||||
|
|
||||||
property real noise_strength: shadersettings.noise_strength
|
property real noise_strength: shadersettings.noise_strength
|
||||||
property real screen_distorsion: shadersettings.screen_distortion
|
property real screen_distorsion: shadersettings.screen_distortion
|
||||||
property real glowing_line_strength: shadersettings.glowing_line_strength
|
property real glowing_line_strength: shadersettings.glowing_line_strength
|
||||||
@ -54,6 +58,23 @@ ShaderEffect {
|
|||||||
property real deltay: 3 / terminal.height
|
property real deltay: 3 / terminal.height
|
||||||
property real deltax: 3 / terminal.width
|
property real deltax: 3 / terminal.width
|
||||||
|
|
||||||
|
//Blurred texture used for bloom
|
||||||
|
Loader{
|
||||||
|
anchors.fill: parent
|
||||||
|
active: bloom !== 0
|
||||||
|
FastBlur{
|
||||||
|
radius: 32
|
||||||
|
anchors.fill: parent
|
||||||
|
source: theSource
|
||||||
|
transparentBorder: true
|
||||||
|
ShaderEffectSource{
|
||||||
|
id: bloomSource
|
||||||
|
sourceItem: parent
|
||||||
|
hideSource: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Timer{
|
Timer{
|
||||||
id: timetimer
|
id: timetimer
|
||||||
onTriggered: time += interval
|
onTriggered: time += interval
|
||||||
@ -62,6 +83,7 @@ ShaderEffect {
|
|||||||
repeat: true
|
repeat: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO fix the glow line which is after the first time
|
||||||
fragmentShader: "
|
fragmentShader: "
|
||||||
uniform sampler2D source;
|
uniform sampler2D source;
|
||||||
uniform highp float qt_Opacity;
|
uniform highp float qt_Opacity;
|
||||||
@ -74,16 +96,17 @@ ShaderEffect {
|
|||||||
uniform highp float deltax;
|
uniform highp float deltax;
|
||||||
uniform highp float deltay;" +
|
uniform highp float deltay;" +
|
||||||
|
|
||||||
(noise_strength !== 0 ? "uniform highp float noise_strength;" : "") +
|
(bloom !== 0 ? "uniform highp sampler2D bloomSource;" : "") +
|
||||||
(screen_distorsion !== 0 ? "uniform highp float screen_distorsion;" : "")+
|
(noise_strength !== 0 ? "uniform highp float noise_strength;" : "") +
|
||||||
(glowing_line_strength !== 0 ? "uniform highp float glowing_line_strength;" : "")+
|
(screen_distorsion !== 0 ? "uniform highp float screen_distorsion;" : "")+
|
||||||
"uniform lowp float brightness;" +
|
(glowing_line_strength !== 0 ? "uniform highp float glowing_line_strength;" : "")+
|
||||||
|
"uniform lowp float brightness;" +
|
||||||
|
|
||||||
(scanlines != 0 ? "uniform highp float scanlines;" : "") +
|
(scanlines != 0 ? "uniform highp float scanlines;" : "") +
|
||||||
|
|
||||||
(shadersettings.screen_flickering !== 0 ? "uniform highp float horizontal_distortion;" : "") +
|
(shadersettings.screen_flickering !== 0 ? "uniform highp float horizontal_distortion;" : "") +
|
||||||
|
|
||||||
"float rand(vec2 co, float time){
|
"float rand(vec2 co, float time){
|
||||||
return fract(sin(dot(co.xy ,vec2(0.37898 * time ,0.78233))) * 437.5875453);
|
return fract(sin(dot(co.xy ,vec2(0.37898 * time ,0.78233))) * 437.5875453);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,44 +120,46 @@ ShaderEffect {
|
|||||||
}" +
|
}" +
|
||||||
|
|
||||||
|
|
||||||
(glowing_line_strength !== 0 ?
|
(glowing_line_strength !== 0 ?
|
||||||
"float randomPass(vec2 coords){
|
"float randomPass(vec2 coords){
|
||||||
return fract(smoothstep(-0.2, 0.0, coords.y - time * 0.0007)) * glowing_line_strength;
|
return fract(smoothstep(-0.2, 0.0, coords.y - 3.0 * fract(time * 0.0002))) * glowing_line_strength;
|
||||||
}" : "") +
|
}" : "") +
|
||||||
|
|
||||||
|
|
||||||
"void main() {" +
|
"void main() {" +
|
||||||
"vec2 cc = vec2(0.5) - qt_TexCoord0;" +
|
"vec2 cc = vec2(0.5) - qt_TexCoord0;" +
|
||||||
"float distance = length(cc);" +
|
"float distance = length(cc);" +
|
||||||
|
|
||||||
(screen_distorsion !== 0 ?
|
(screen_distorsion !== 0 ?
|
||||||
"float distortion = dot(cc, cc) * screen_distorsion;
|
"float distortion = dot(cc, cc) * screen_distorsion;
|
||||||
vec2 coords = (qt_TexCoord0 - cc * (1.0 + distortion) * distortion);"
|
vec2 coords = (qt_TexCoord0 - cc * (1.0 + distortion) * distortion);"
|
||||||
:"vec2 coords = qt_TexCoord0;") +
|
:"vec2 coords = qt_TexCoord0;") +
|
||||||
|
|
||||||
(shadersettings.horizontal_sincronization !== 0 ?
|
(shadersettings.horizontal_sincronization !== 0 ?
|
||||||
"float h_distortion = 0.5 * sin(time*0.001 + coords.y*10.0*fract(time/10.0));
|
"float h_distortion = 0.5 * sin(time*0.001 + coords.y*10.0*fract(time/10.0));
|
||||||
h_distortion += 0.5 * cos(time*0.04 + 0.03 + coords.y*50.0*fract(time/10.0 + 0.4));
|
h_distortion += 0.5 * cos(time*0.04 + 0.03 + coords.y*50.0*fract(time/10.0 + 0.4));
|
||||||
coords.x = coords.x + h_distortion * 0.3 * horizontal_distortion;" +
|
coords.x = coords.x + h_distortion * 0.3 * horizontal_distortion;" +
|
||||||
(noise_strength ? "noise_strength += horizontal_distortion * 0.5;" : "")
|
(noise_strength ? "noise_strength += horizontal_distortion * 0.5;" : "")
|
||||||
: "") +
|
: "") +
|
||||||
|
|
||||||
"float color = texture2D(source, coords).r;" +
|
"float color = texture2D(source, coords).r;" +
|
||||||
|
|
||||||
(scanlines !== 0 ?
|
(bloom !== 0 ? "color += texture2D(bloomSource, coords).r *" + 2.5 * bloom + ";" : "") +
|
||||||
"float scanline_alpha = getScanlineIntensity(coords);" : "float scanline_alpha = 0.0;") +
|
|
||||||
|
|
||||||
(noise_strength !== 0 ?
|
(scanlines !== 0 ?
|
||||||
"color += stepNoise(coords) * noise_strength * (1.0 - distance * distance * 2.0);" : "") +
|
"float scanline_alpha = getScanlineIntensity(coords);" : "float scanline_alpha = 0.0;") +
|
||||||
|
|
||||||
(glowing_line_strength !== 0 ?
|
(noise_strength !== 0 ?
|
||||||
"color += randomPass(coords) * glowing_line_strength;" : "") +
|
"color += stepNoise(coords) * noise_strength * (1.0 - distance * distance * 2.0);" : "") +
|
||||||
|
|
||||||
"vec3 finalColor = mix(background_color, font_color, color).rgb;" +
|
(glowing_line_strength !== 0 ?
|
||||||
"finalColor = mix(finalColor * 1.1, vec3(0.0), 1.2 * distance * distance + scanline_alpha);" +
|
"color += randomPass(coords) * glowing_line_strength;" : "") +
|
||||||
|
|
||||||
(screen_flickering !== 0 ?
|
"vec3 finalColor = mix(background_color, font_color, color).rgb;" +
|
||||||
"finalColor = mix(finalColor, vec3(0.0), brightness);" : "") +
|
"finalColor = mix(finalColor * 1.1, vec3(0.0), 1.2 * distance * distance + scanline_alpha);" +
|
||||||
"gl_FragColor = vec4(finalColor, 1.0);
|
|
||||||
|
(screen_flickering !== 0 ?
|
||||||
|
"finalColor = mix(finalColor, vec3(0.0), brightness);" : "") +
|
||||||
|
"gl_FragColor = vec4(finalColor, 1.0);
|
||||||
}"
|
}"
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ Item{
|
|||||||
property real screen_distortion: 0.15
|
property real screen_distortion: 0.15
|
||||||
property real glowing_line_strength: 0.4
|
property real glowing_line_strength: 0.4
|
||||||
property real motion_blur: 0.65
|
property real motion_blur: 0.65
|
||||||
property real bloom_strength: 0.8
|
property real bloom_strength: 0.6
|
||||||
|
|
||||||
property real horizontal_sincronization: 0.1
|
property real horizontal_sincronization: 0.1
|
||||||
property real screen_flickering: 0.12
|
property real screen_flickering: 0.12
|
||||||
|
@ -49,23 +49,7 @@ Item{
|
|||||||
sourceItem: kterminal
|
sourceItem: kterminal
|
||||||
hideSource: true
|
hideSource: true
|
||||||
}
|
}
|
||||||
Loader{
|
|
||||||
anchors.fill: parent
|
|
||||||
active: mBloom !== 0
|
|
||||||
FastBlur{
|
|
||||||
id: bloom
|
|
||||||
source: kterminal
|
|
||||||
radius: 32
|
|
||||||
anchors.fill: parent
|
|
||||||
transparentBorder: true
|
|
||||||
ShaderEffectSource{
|
|
||||||
id: bloomSource
|
|
||||||
sourceItem: bloom
|
|
||||||
hideSource: true
|
|
||||||
live: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loader{
|
Loader{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
active: mBlur !== 0
|
active: mBlur !== 0
|
||||||
@ -74,7 +58,6 @@ Item{
|
|||||||
sourceItem: blurredterminal
|
sourceItem: blurredterminal
|
||||||
recursive: true
|
recursive: true
|
||||||
live: true
|
live: true
|
||||||
smooth: false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +66,6 @@ Item{
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
property variant source: source
|
property variant source: source
|
||||||
property variant blurredSource: (mBlur !== 0) ? blurredSource : undefined
|
property variant blurredSource: (mBlur !== 0) ? blurredSource : undefined
|
||||||
property variant bloomSource: (mBloom !== 0) ? bloomSource : undefined
|
|
||||||
z: 2
|
z: 2
|
||||||
|
|
||||||
fragmentShader:
|
fragmentShader:
|
||||||
@ -94,14 +76,9 @@ Item{
|
|||||||
|
|
||||||
(mBlur !== 0 ?
|
(mBlur !== 0 ?
|
||||||
"uniform lowp sampler2D blurredSource;" : "") +
|
"uniform lowp sampler2D blurredSource;" : "") +
|
||||||
(mBloom !== 0 ?
|
|
||||||
"uniform lowp sampler2D bloomSource;" : "") +
|
|
||||||
|
|
||||||
"void main() {" +
|
"void main() {" +
|
||||||
"float color = texture2D(source, qt_TexCoord0).r * 0.8 * 512.0;" +
|
"float color = texture2D(source, qt_TexCoord0).r * 0.8 * 512.0;" +
|
||||||
(mBloom !== 0 ?
|
|
||||||
"color += texture2D(bloomSource, qt_TexCoord0).r * 512.0 *" + mBloom + ";" : ""
|
|
||||||
) +
|
|
||||||
(mBlur !== 0 ?
|
(mBlur !== 0 ?
|
||||||
"float blurredSourceColor = texture2D(blurredSource, qt_TexCoord0).r * 512.0;" +
|
"float blurredSourceColor = texture2D(blurredSource, qt_TexCoord0).r * 512.0;" +
|
||||||
"color = mix(blurredSourceColor, color, " + motionBlurCoefficient + ");" : ""
|
"color = mix(blurredSourceColor, color, " + motionBlurCoefficient + ");" : ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user