2021-06-30 22:49:03 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2013-2021 "Filippo Scognamiglio"
|
|
|
|
* https://github.com/Swordfish90/cool-retro-term
|
|
|
|
*
|
|
|
|
* This file is part of cool-retro-term.
|
|
|
|
*
|
|
|
|
* cool-retro-term is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*******************************************************************************/
|
2018-11-30 00:57:59 +01:00
|
|
|
import QtQuick 2.0
|
|
|
|
|
|
|
|
import "utils.js" as Utils
|
|
|
|
|
|
|
|
ShaderEffect {
|
2018-12-16 22:30:03 +01:00
|
|
|
property color _staticFrameColor: "#ffffff"
|
2018-12-01 19:16:33 +01:00
|
|
|
property color _backgroundColor: appSettings.backgroundColor
|
|
|
|
property color _fontColor: appSettings.fontColor
|
|
|
|
property color _lightColor: Utils.mix(_fontColor, _backgroundColor, 0.2)
|
|
|
|
property real _ambientLight: Utils.lint(0.2, 0.8, appSettings.ambientLight)
|
2018-11-30 00:57:59 +01:00
|
|
|
|
2018-12-01 19:16:33 +01:00
|
|
|
property color frameColor: Utils.mix(_staticFrameColor, _lightColor, _ambientLight)
|
2018-11-30 00:57:59 +01:00
|
|
|
property real screenCurvature: appSettings.screenCurvature * appSettings.screenCurvatureSize
|
2018-12-01 19:16:33 +01:00
|
|
|
property real shadowLength: 0.5 * screenCurvature * Utils.lint(0.50, 1.5, _ambientLight)
|
2018-11-30 00:57:59 +01:00
|
|
|
|
2018-12-13 23:55:07 +01:00
|
|
|
property size aadelta: Qt.size(1.0 / width, 1.0 / height)
|
|
|
|
|
2021-07-03 16:14:02 +02:00
|
|
|
ShaderLibrary {
|
|
|
|
id: shaderLibrary
|
|
|
|
}
|
|
|
|
|
2018-11-30 00:57:59 +01:00
|
|
|
fragmentShader: "
|
|
|
|
#ifdef GL_ES
|
|
|
|
precision mediump float;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
uniform lowp float screenCurvature;
|
2018-12-01 19:16:33 +01:00
|
|
|
uniform lowp float shadowLength;
|
2018-11-30 00:57:59 +01:00
|
|
|
uniform highp float qt_Opacity;
|
|
|
|
uniform lowp vec4 frameColor;
|
2018-12-13 23:55:07 +01:00
|
|
|
uniform mediump vec2 aadelta;
|
2018-11-30 00:57:59 +01:00
|
|
|
|
|
|
|
varying highp vec2 qt_TexCoord0;
|
|
|
|
|
|
|
|
vec2 distortCoordinates(vec2 coords){
|
|
|
|
vec2 cc = (coords - vec2(0.5));
|
|
|
|
float dist = dot(cc, cc) * screenCurvature;
|
|
|
|
return (coords + cc * (1.0 + dist) * dist);
|
|
|
|
}
|
2021-07-03 16:14:02 +02:00
|
|
|
" +
|
2018-11-30 00:57:59 +01:00
|
|
|
|
2021-07-03 16:14:02 +02:00
|
|
|
shaderLibrary.max2 +
|
|
|
|
shaderLibrary.min2 +
|
|
|
|
shaderLibrary.prod2 +
|
|
|
|
shaderLibrary.sum2 +
|
2018-12-01 19:16:33 +01:00
|
|
|
|
2021-07-03 16:14:02 +02:00
|
|
|
"
|
2018-11-30 00:57:59 +01:00
|
|
|
|
|
|
|
void main(){
|
|
|
|
vec2 staticCoords = qt_TexCoord0;
|
|
|
|
vec2 coords = distortCoordinates(staticCoords);
|
|
|
|
|
2018-12-01 19:16:33 +01:00
|
|
|
vec3 color = vec3(0.0);
|
|
|
|
float alpha = 0.0;
|
|
|
|
|
|
|
|
float outShadowLength = shadowLength;
|
2018-12-16 22:30:03 +01:00
|
|
|
float inShadowLength = shadowLength * 0.5;
|
2018-11-30 00:57:59 +01:00
|
|
|
|
2018-12-01 19:16:33 +01:00
|
|
|
float outShadow = max2(1.0 - smoothstep(vec2(-outShadowLength), vec2(0.0), coords) + smoothstep(vec2(1.0), vec2(1.0 + outShadowLength), coords));
|
2019-01-02 22:01:57 +01:00
|
|
|
outShadow = clamp(sqrt(outShadow), 0.0, 1.0);
|
2018-12-13 23:55:07 +01:00
|
|
|
color += frameColor.rgb * outShadow;
|
|
|
|
alpha = sum2(1.0 - smoothstep(vec2(0.0), aadelta, coords) + smoothstep(vec2(1.0) - aadelta, vec2(1.0), coords));
|
|
|
|
alpha = clamp(alpha, 0.0, 1.0) * mix(1.0, 0.9, outShadow);
|
2018-11-30 00:57:59 +01:00
|
|
|
|
2018-12-16 22:30:03 +01:00
|
|
|
float inShadow = 1.0 - prod2(smoothstep(0.0, inShadowLength, coords) - smoothstep(1.0 - inShadowLength, 1.0, coords));
|
|
|
|
inShadow = 0.5 * inShadow * inShadow;
|
|
|
|
alpha = max(alpha, inShadow);
|
|
|
|
|
2018-11-30 00:57:59 +01:00
|
|
|
gl_FragColor = vec4(color * alpha, alpha);
|
|
|
|
}
|
|
|
|
"
|
|
|
|
|
|
|
|
onStatusChanged: if (log) console.log(log) //Print warning messages
|
|
|
|
}
|