mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-01-31 02:01:19 +00:00
Much better rendering of frame. Minor clenups. Little bit of eyecandy.
This commit is contained in:
parent
1d8000a7f8
commit
75a73011fb
@ -59,25 +59,23 @@ ApplicationWindow{
|
|||||||
visible: true
|
visible: true
|
||||||
|
|
||||||
Item{
|
Item{
|
||||||
|
id: maincontainer
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.topMargin: 30 //Fix the constant
|
anchors.top: menuBar.bottom
|
||||||
|
clip: true
|
||||||
ShaderSettings{
|
ShaderSettings{
|
||||||
id: shadersettings
|
id: shadersettings
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderEffectSource{
|
ShaderEffectSource{
|
||||||
property double offset_top: 0.03
|
|
||||||
property double offset_bottom: 0.04
|
|
||||||
id: theSource
|
id: theSource
|
||||||
sourceItem: terminal
|
sourceItem: terminal
|
||||||
sourceRect: Qt.rect(-offset_top * terminal.width, -offset_top * terminal.height, terminal.width + offset_bottom * terminal.width, terminal.height + offset_bottom * terminal.height)
|
sourceRect: Qt.rect(-65, -75, terminal.width + 130, terminal.height + 150)
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderEffect {
|
ShaderEffect {
|
||||||
id: shadercontainer
|
id: shadercontainer
|
||||||
width: parent.width
|
anchors.fill: terminal
|
||||||
height: parent.height
|
|
||||||
anchors.centerIn: parent
|
|
||||||
blending: true
|
blending: true
|
||||||
z: 2
|
z: 2
|
||||||
property color font_color: shadersettings.font_color
|
property color font_color: shadersettings.font_color
|
||||||
@ -91,15 +89,21 @@ ApplicationWindow{
|
|||||||
property real glowing_line_strength: shadersettings.glowing_line_strength
|
property real glowing_line_strength: shadersettings.glowing_line_strength
|
||||||
property real brightness: 1.0
|
property real brightness: 1.0
|
||||||
|
|
||||||
|
property real scanlines: shadersettings.scanlines ? 1.0 : 0.0
|
||||||
|
|
||||||
NumberAnimation on brightness{
|
NumberAnimation on brightness{
|
||||||
|
property real randval: 0
|
||||||
to: 1.0
|
to: 1.0
|
||||||
duration: 300
|
duration: 300
|
||||||
onStopped: {to = 1 - Math.random() * shadersettings.brightness_flickering; start();}
|
onStopped: {
|
||||||
running: true
|
to = 1 - Math.random() * shadersettings.brightness_flickering;
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
running: false
|
||||||
}
|
}
|
||||||
|
|
||||||
property real deltay: 1.0 / terminal.height
|
property real deltay: 3 / terminal.height
|
||||||
property real deltax: 1.0 / terminal.width
|
property real deltax: 3 / terminal.width
|
||||||
//property real faulty_screen_prob: shadersettings.faulty_screen_prob
|
//property real faulty_screen_prob: shadersettings.faulty_screen_prob
|
||||||
|
|
||||||
NumberAnimation on time{
|
NumberAnimation on time{
|
||||||
@ -128,6 +132,8 @@ ApplicationWindow{
|
|||||||
uniform highp float deltax;
|
uniform highp float deltax;
|
||||||
uniform highp float deltay;
|
uniform highp float deltay;
|
||||||
|
|
||||||
|
uniform highp float scanlines;
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -138,7 +144,7 @@ ApplicationWindow{
|
|||||||
}
|
}
|
||||||
|
|
||||||
float getScanlineIntensity(vec2 pos){
|
float getScanlineIntensity(vec2 pos){
|
||||||
return 0.5 + abs(sin(pos.y * txt_Size.y)) * 0.5;
|
return abs(sin(pos.y * txt_Size.y)) * 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 distortCoordinates(vec2 coords){
|
vec2 distortCoordinates(vec2 coords){
|
||||||
@ -172,33 +178,43 @@ ApplicationWindow{
|
|||||||
//coords.x = coords.x + sin(coords.y * 5.0) * 0.05 * step(faulty_screen_prob, rand(txt_Size, floor(time)));
|
//coords.x = coords.x + sin(coords.y * 5.0) * 0.05 * step(faulty_screen_prob, rand(txt_Size, floor(time)));
|
||||||
|
|
||||||
//vec4 color = texture2D(source, coords);
|
//vec4 color = texture2D(source, coords);
|
||||||
vec4 color = blurredColor(source, coords) * brightness;
|
float color = (blurredColor(source, coords).r + texture2D(source, coords).r) * 0.5;
|
||||||
float scanline_alpha = getScanlineIntensity(coords);
|
float scanline_alpha = getScanlineIntensity(coords) * scanlines;
|
||||||
float inside = step(0.0, coords.x) * step(-1.0, -coords.x) * step(0.0, coords.y) * step(-1.0, -coords.y);
|
//float inside = step(0.0, coords.x) * step(-1.0, -coords.x) * step(0.0, coords.y) * step(-1.0, -coords.y);
|
||||||
float noise = stepNoise(coords) * noise_strength;
|
float noise = stepNoise(coords) * noise_strength;
|
||||||
float randomPass = randomPass(coords) * glowing_line_strength;
|
float randomPass = randomPass(coords) * glowing_line_strength;
|
||||||
vec4 added_color = (noise + randomPass) * font_color;
|
color += noise + randomPass;
|
||||||
vec4 finalColor = color + added_color;
|
vec3 finalColor = mix(background_color, font_color, color).rgb;
|
||||||
finalColor = mix(finalColor, background_color, 1.0 - scanline_alpha);
|
finalColor = mix(finalColor, vec3(0.0), scanline_alpha);
|
||||||
gl_FragColor = vec4(finalColor.rgb, 1.0);
|
gl_FragColor = vec4(finalColor * brightness, 1.0);
|
||||||
}"
|
}"
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderEffect{
|
ShaderEffect{
|
||||||
z: 2.1
|
z: 2.1
|
||||||
width: parent.width * 1.05
|
|
||||||
height: parent.height * 1.05
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
anchors.fill: frame
|
||||||
|
clip: true
|
||||||
|
blending: true
|
||||||
|
|
||||||
property variant source: framesource
|
property variant source: framesource
|
||||||
property real screen_distorsion: shadersettings.screen_distortion - 0.22
|
property variant normals: framesourcenormals
|
||||||
|
property real screen_distorsion: shadersettings.screen_distortion
|
||||||
property real ambient_light: shadersettings.ambient_light
|
property real ambient_light: shadersettings.ambient_light
|
||||||
|
property color font_color: shadersettings.font_color
|
||||||
|
property color background_color: shadersettings.background_color
|
||||||
|
property real brightness: shadercontainer.brightness
|
||||||
|
|
||||||
fragmentShader: "
|
fragmentShader: "
|
||||||
uniform sampler2D source;
|
uniform sampler2D source;
|
||||||
|
uniform sampler2D normals;
|
||||||
uniform highp float screen_distorsion;
|
uniform highp float screen_distorsion;
|
||||||
uniform highp float ambient_light;
|
uniform highp float ambient_light;
|
||||||
|
|
||||||
|
uniform highp vec4 font_color;
|
||||||
|
uniform highp vec4 background_color;
|
||||||
|
uniform highp float brightness;
|
||||||
|
|
||||||
varying highp vec2 qt_TexCoord0;
|
varying highp vec2 qt_TexCoord0;
|
||||||
|
|
||||||
vec2 distortCoordinates(vec2 coords){
|
vec2 distortCoordinates(vec2 coords){
|
||||||
@ -210,8 +226,12 @@ ApplicationWindow{
|
|||||||
void main(){
|
void main(){
|
||||||
vec2 coords = distortCoordinates(qt_TexCoord0);
|
vec2 coords = distortCoordinates(qt_TexCoord0);
|
||||||
vec4 txt_color = texture2D(source, coords);
|
vec4 txt_color = texture2D(source, coords);
|
||||||
vec4 final_color = mix(txt_color, vec4(vec3(0.0), 1.0), 1.0 - ambient_light);
|
vec4 normala = texture2D(normals, coords);
|
||||||
gl_FragColor = vec4(final_color.rgb, txt_color.a);
|
vec3 normal = normalize(normala.rgb) * txt_color.a;
|
||||||
|
float reflection = dot(normal, vec3(1.0, 1.0, 0.0)) * 0.3 * brightness;
|
||||||
|
vec3 reflection_color = mix(font_color, background_color, 0.7).rgb * reflection;
|
||||||
|
vec3 final_color = mix(txt_color.rgb, reflection_color, 1.0 - ambient_light);
|
||||||
|
gl_FragColor = vec4(final_color, txt_color.a);
|
||||||
}"
|
}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,15 +239,37 @@ ApplicationWindow{
|
|||||||
id: framesource
|
id: framesource
|
||||||
sourceItem: frame
|
sourceItem: frame
|
||||||
hideSource: true
|
hideSource: true
|
||||||
live: false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Image{
|
ShaderEffectSource{
|
||||||
|
id: framesourcenormals
|
||||||
|
sourceItem: framenormals
|
||||||
|
hideSource: true
|
||||||
|
}
|
||||||
|
|
||||||
|
BorderImage{
|
||||||
id: frame
|
id: frame
|
||||||
source: "../images/squared_frame.png"
|
width: parent.width + 140
|
||||||
|
height: parent.height + 140
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
visible: true
|
source: "../images/screen-frame.png"
|
||||||
opacity: shadersettings.ambient_light
|
border {left: 116; right: 116; top: 116; bottom: 116}
|
||||||
|
horizontalTileMode: BorderImage.Stretch
|
||||||
|
verticalTileMode: BorderImage.Stretch
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
|
||||||
|
BorderImage{
|
||||||
|
id: framenormals
|
||||||
|
anchors.fill: frame
|
||||||
|
source: "../images/screen-frame-normals.png"
|
||||||
|
border.bottom: frame.border.bottom
|
||||||
|
border.top: frame.border.top
|
||||||
|
border.left: frame.border.left
|
||||||
|
border.right: frame.border.right
|
||||||
|
horizontalTileMode: BorderImage.Stretch
|
||||||
|
verticalTileMode: BorderImage.Stretch
|
||||||
|
visible: false
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminalScreen {
|
TerminalScreen {
|
||||||
@ -245,10 +287,10 @@ ApplicationWindow{
|
|||||||
z: 4
|
z: 4
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cached: true
|
cached: true
|
||||||
opacity: 0.2
|
opacity: 0.1
|
||||||
gradient: Gradient{
|
gradient: Gradient{
|
||||||
GradientStop{position: 0.0; color: shadersettings.font_color}
|
GradientStop{position: 0.0; color: shadersettings.font_color}
|
||||||
GradientStop{position: 1.0; color: shadersettings.background_color}
|
GradientStop{position: 1.0; color: "#00000000"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user