1
0
mirror of https://github.com/Swordfish90/cool-retro-term.git synced 2025-01-31 10:11:20 +00:00

Moved bloom where it belongs, in postprocessing instead of preprocessing. Restored glowing line animation.

This commit is contained in:
Filippo Scognamiglio 2014-03-26 20:26:20 +01:00
parent a729eae191
commit 8cb9520ea7
3 changed files with 59 additions and 57 deletions

View File

@ -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,6 +96,7 @@ ShaderEffect {
uniform highp float deltax; uniform highp float deltax;
uniform highp float deltay;" + uniform highp float deltay;" +
(bloom !== 0 ? "uniform highp sampler2D bloomSource;" : "") +
(noise_strength !== 0 ? "uniform highp float noise_strength;" : "") + (noise_strength !== 0 ? "uniform highp float noise_strength;" : "") +
(screen_distorsion !== 0 ? "uniform highp float screen_distorsion;" : "")+ (screen_distorsion !== 0 ? "uniform highp float screen_distorsion;" : "")+
(glowing_line_strength !== 0 ? "uniform highp float glowing_line_strength;" : "")+ (glowing_line_strength !== 0 ? "uniform highp float glowing_line_strength;" : "")+
@ -99,7 +122,7 @@ 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;
}" : "") + }" : "") +
@ -121,6 +144,8 @@ ShaderEffect {
"float color = texture2D(source, coords).r;" + "float color = texture2D(source, coords).r;" +
(bloom !== 0 ? "color += texture2D(bloomSource, coords).r *" + 2.5 * bloom + ";" : "") +
(scanlines !== 0 ? (scanlines !== 0 ?
"float scanline_alpha = getScanlineIntensity(coords);" : "float scanline_alpha = 0.0;") + "float scanline_alpha = getScanlineIntensity(coords);" : "float scanline_alpha = 0.0;") +

View File

@ -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

View File

@ -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 + ");" : ""