mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-01-31 02:01:19 +00:00
Added bloom effect!
This commit is contained in:
parent
5076bf58b3
commit
d0e4086d86
@ -138,6 +138,11 @@ ApplicationWindow {
|
||||
checked: shadersettings.scanlines
|
||||
onCheckedChanged: shadersettings.scanlines = checked;
|
||||
}
|
||||
SettingComponent{
|
||||
name: "Bloom"
|
||||
onValueChanged: shadersettings.bloom_strength = value
|
||||
_value: shadersettings.bloom_strength
|
||||
}
|
||||
SettingComponent{
|
||||
name: "Motion Blur"
|
||||
onValueChanged: shadersettings.motion_blur = value
|
||||
|
@ -131,20 +131,6 @@ ShaderEffect {
|
||||
}" : "") +
|
||||
|
||||
|
||||
"vec4 blurredColor(sampler2D source, vec2 coords){
|
||||
vec4 sum = vec4(0.0);
|
||||
sum += texture2D(source, coords - vec2(-deltax, -deltay)) * 0.11;
|
||||
sum += texture2D(source, coords - vec2(-deltax, 0.0)) * 0.11;
|
||||
sum += texture2D(source, coords - vec2(-deltax, +deltay)) * 0.11;
|
||||
sum += texture2D(source, coords - vec2(0.0, -deltay)) * 0.11;
|
||||
sum += texture2D(source, coords - vec2(0.0, 0.0)) * 0.11;
|
||||
sum += texture2D(source, coords - vec2(0.0, +deltay)) * 0.11;
|
||||
sum += texture2D(source, coords - vec2(+deltax, -deltay)) * 0.11;
|
||||
sum += texture2D(source, coords - vec2(+deltax, 0.0)) * 0.11;
|
||||
sum += texture2D(source, coords - vec2(+deltax, +deltay)) * 0.11;
|
||||
return sum;
|
||||
}" +
|
||||
|
||||
"void main() {" +
|
||||
(screen_distorsion !== 0 ? "vec2 coords = distortCoordinates(qt_TexCoord0);" : "vec2 coords = qt_TexCoord0;") +
|
||||
|
||||
@ -152,7 +138,7 @@ ShaderEffect {
|
||||
"float distortion = (sin(coords.y * 20.0 * fract(time * 0.1) + sin(fract(time * 0.2))) + sin(time * 0.05));
|
||||
coords.x = coords.x + distortion * 0.3 * horizontal_distortion; " : "") +
|
||||
|
||||
"float color = (blurredColor(source, coords).r + texture2D(source, coords).r) * 0.5;" +
|
||||
"float color = texture2D(source, coords).r;" +
|
||||
|
||||
(scanlines !== 0 ?
|
||||
"float scanline_alpha = getScanlineIntensity(coords);" : "float scanline_alpha = 0.0;") +
|
||||
|
@ -33,6 +33,7 @@ Item{
|
||||
property real screen_distortion: 0.15
|
||||
property real glowing_line_strength: 0.4
|
||||
property real motion_blur: 0.65
|
||||
property real bloom_strength: 0.8
|
||||
|
||||
property bool scanlines: false
|
||||
|
||||
@ -114,6 +115,7 @@ Item{
|
||||
scanlines = settings.scanlines ? settings.scanlines : scanlines;
|
||||
|
||||
motion_blur = settings.motion_blur ? settings.motion_blur : motion_blur
|
||||
bloom_strength = settings.bloom_strength ? settings.bloom_strength : bloom_strength
|
||||
|
||||
frames_index = settings.frames_index ? settings.frames_index : frames_index;
|
||||
|
||||
@ -134,7 +136,8 @@ Item{
|
||||
frames_index: frames_index,
|
||||
font_index: font_index,
|
||||
font_scaling: font_scaling,
|
||||
motion_blur: motion_blur
|
||||
motion_blur: motion_blur,
|
||||
bloom_strength: bloom_strength
|
||||
}
|
||||
|
||||
console.log(JSON.stringify(settings));
|
||||
|
@ -1,13 +1,16 @@
|
||||
import QtQuick 2.0
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
import org.kde.konsole 0.1
|
||||
|
||||
Item{
|
||||
id: terminalContainer
|
||||
property real blur: shadersettings.motion_blur
|
||||
property real motionBlurCoefficient: (_minBlurCoefficient)*blur + (_maxBlurCoefficient)*(1.0-blur)
|
||||
property real mBloom: shadersettings.bloom_strength
|
||||
property real mBlur: shadersettings.motion_blur
|
||||
property real motionBlurCoefficient: (_minBlurCoefficient)*mBlur + (_maxBlurCoefficient)*(1.0-mBlur)
|
||||
property real _minBlurCoefficient: 0.015
|
||||
property real _maxBlurCoefficient: 0.10
|
||||
|
||||
KTerminal {
|
||||
id: kterminal
|
||||
font.pointSize: shadersettings.fontSize
|
||||
@ -33,40 +36,66 @@ Item{
|
||||
}
|
||||
}
|
||||
|
||||
Loader{
|
||||
anchors.fill: parent
|
||||
active: parent.blur !== 0
|
||||
|
||||
sourceComponent: Item{
|
||||
ShaderEffectSource{
|
||||
id: source
|
||||
sourceItem: kterminal
|
||||
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{
|
||||
anchors.fill: parent
|
||||
active: mBlur !== 0
|
||||
ShaderEffectSource{
|
||||
id: blurredSource
|
||||
sourceItem: blurredterminal
|
||||
recursive: true
|
||||
live: true
|
||||
}
|
||||
}
|
||||
ShaderEffect {
|
||||
id: blurredterminal
|
||||
anchors.fill: parent
|
||||
property variant source: source
|
||||
property variant blurredSource: blurredSource
|
||||
property variant blurredSource: (mBlur !== 0) ? blurredSource : undefined
|
||||
property variant bloomSource: (mBloom !== 0) ? bloomSource : undefined
|
||||
z: 2
|
||||
fragmentShader:
|
||||
"uniform lowp float qt_Opacity;" +
|
||||
"uniform lowp sampler2D source;" +
|
||||
"uniform lowp sampler2D blurredSource;" +
|
||||
|
||||
"varying highp vec2 qt_TexCoord0;" +
|
||||
|
||||
(mBlur !== 0 ?
|
||||
"uniform lowp sampler2D blurredSource;" : "") +
|
||||
(mBloom !== 0 ?
|
||||
"uniform lowp sampler2D bloomSource;" : "") +
|
||||
|
||||
"void main() {" +
|
||||
" float sourceColor = texture2D(source, qt_TexCoord0).r * 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 ?
|
||||
"float blurredSourceColor = texture2D(blurredSource, qt_TexCoord0).r * 512.0;" +
|
||||
" gl_FragColor = vec4(vec3(floor(mix(blurredSourceColor, sourceColor, " + motionBlurCoefficient + "))) / 512.0, 1.0);" +
|
||||
"color = mix(blurredSourceColor, color, " + motionBlurCoefficient + ");" : ""
|
||||
) +
|
||||
"gl_FragColor = vec4(vec3(floor(color) / 512.0), 1.0);" +
|
||||
"}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user