mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-01-18 12:15:27 +00:00
First implementation of imageless frame.
This commit is contained in:
parent
0f89936e01
commit
555783af4c
@ -27,10 +27,9 @@ QtObject{
|
||||
readonly property string version: "1.1.0"
|
||||
readonly property int profileVersion: 2
|
||||
|
||||
|
||||
// STATIC CONSTANTS ////////////////////////////////////////////////////////
|
||||
|
||||
readonly property real screenCurvatureSize: 0.2
|
||||
readonly property real screenCurvatureSize: 0.4
|
||||
readonly property real minimumFontScaling: 0.25
|
||||
readonly property real maximumFontScaling: 2.50
|
||||
|
||||
@ -176,52 +175,6 @@ QtObject{
|
||||
terminalFontChanged(fontFamily, pixelSize, lineSpacing, screenScaling, fontWidth);
|
||||
}
|
||||
|
||||
// FRAMES /////////////////////////////////////////////////////////////////
|
||||
|
||||
property ListModel framesList: ListModel{
|
||||
ListElement{
|
||||
name: "NO_FRAME"
|
||||
text: "No frame"
|
||||
source: ""
|
||||
reflections: false
|
||||
}
|
||||
ListElement{
|
||||
name: "SIMPLE_WHITE_FRAME"
|
||||
text: "Simple white frame"
|
||||
source: "./frames/WhiteSimpleFrame.qml"
|
||||
reflections: true
|
||||
}
|
||||
ListElement{
|
||||
name: "ROUGH_BLACK_FRAME"
|
||||
text: "Rough black frame"
|
||||
source: "./frames/BlackRoughFrame.qml"
|
||||
reflections: true
|
||||
}
|
||||
}
|
||||
|
||||
function getFrameIndexByName(name) {
|
||||
for (var i = 0; i < framesList.count; i++) {
|
||||
if (name === framesList.get(i).name)
|
||||
return i;
|
||||
}
|
||||
return 0; // If the frame is not available default to 0.
|
||||
}
|
||||
|
||||
property string frameSource: "./frames/WhiteSimpleFrame.qml"
|
||||
property string frameName: "SIMPLE_WHITE_FRAME"
|
||||
|
||||
property bool _frameReflections: false
|
||||
property bool reflectionsAllowed: true
|
||||
property bool frameReflections: _frameReflections && reflectionsAllowed
|
||||
|
||||
onFrameNameChanged: {
|
||||
var index = getFrameIndexByName(frameName);
|
||||
frameSource = framesList.get(index).source;
|
||||
reflectionsAllowed = framesList.get(index).reflections;
|
||||
}
|
||||
|
||||
// DB STORAGE /////////////////////////////////////////////////////////////
|
||||
|
||||
property Storage storage: Storage{ }
|
||||
|
||||
function stringify(obj) {
|
||||
@ -242,7 +195,6 @@ QtObject{
|
||||
showTerminalSize: showTerminalSize,
|
||||
fontScaling: fontScaling,
|
||||
fontNames: fontNames,
|
||||
frameReflections: _frameReflections,
|
||||
showMenubar: showMenubar,
|
||||
bloomQuality: bloomQuality,
|
||||
burnInQuality: burnInQuality,
|
||||
@ -263,7 +215,6 @@ QtObject{
|
||||
saturationColor: saturationColor,
|
||||
screenCurvature: screenCurvature,
|
||||
glowingLine: glowingLine,
|
||||
frameName: frameName,
|
||||
burnIn: burnIn,
|
||||
bloom: bloom,
|
||||
rasterization: rasterization,
|
||||
@ -326,8 +277,6 @@ QtObject{
|
||||
fontNames = settings.fontNames !== undefined ? settings.fontNames : fontNames
|
||||
fontScaling = settings.fontScaling !== undefined ? settings.fontScaling : fontScaling
|
||||
|
||||
_frameReflections = settings.frameReflections !== undefined ? settings.frameReflections : _frameReflections;
|
||||
|
||||
showMenubar = settings.showMenubar !== undefined ? settings.showMenubar : showMenubar;
|
||||
|
||||
bloomQuality = settings.bloomQuality !== undefined ? settings.bloomQuality : bloomQuality;
|
||||
@ -354,8 +303,6 @@ QtObject{
|
||||
burnIn = settings.burnIn !== undefined ? settings.burnIn : burnIn
|
||||
bloom = settings.bloom !== undefined ? settings.bloom : bloom
|
||||
|
||||
frameName = settings.frameName !== undefined ? settings.frameName : frameName;
|
||||
|
||||
rasterization = settings.rasterization !== undefined ? settings.rasterization : rasterization;
|
||||
|
||||
jitter = settings.jitter !== undefined ? settings.jitter : jitter;
|
||||
@ -431,7 +378,6 @@ QtObject{
|
||||
"fontColor": "#ff8100",
|
||||
"fontName": "TERMINUS_SCALED",
|
||||
"fontWidth": 1,
|
||||
"frameName": "SIMPLE_WHITE_FRAME",
|
||||
"glowingLine": 0.2,
|
||||
"horizontalSync": 0.08,
|
||||
"jitter": 0.1997,
|
||||
@ -459,7 +405,6 @@ QtObject{
|
||||
"fontColor": "#0ccc68",
|
||||
"fontName": "TERMINUS_SCALED",
|
||||
"fontWidth": 1,
|
||||
"frameName": "SIMPLE_WHITE_FRAME",
|
||||
"glowingLine": 0.2,
|
||||
"horizontalSync": 0.08,
|
||||
"jitter": 0.1997,
|
||||
@ -487,7 +432,6 @@ QtObject{
|
||||
"fontColor": "#7cff4f",
|
||||
"fontName": "PRO_FONT_SCALED",
|
||||
"fontWidth": 1,
|
||||
"frameName": "NO_FRAME",
|
||||
"glowingLine": 0.2,
|
||||
"horizontalSync": 0.151,
|
||||
"jitter": 0.11,
|
||||
@ -515,7 +459,6 @@ QtObject{
|
||||
"fontColor": "#ffffff",
|
||||
"fontName": "COMMODORE_PET",
|
||||
"fontWidth": 1,
|
||||
"frameName": "NO_FRAME",
|
||||
"glowingLine": 0.2,
|
||||
"horizontalSync": 0.151,
|
||||
"jitter": 0,
|
||||
@ -543,7 +486,6 @@ QtObject{
|
||||
"fontColor": "#00d56d",
|
||||
"fontName": "APPLE_II",
|
||||
"fontWidth": 1,
|
||||
"frameName": "SIMPLE_WHITE_FRAME",
|
||||
"glowingLine": 0.22,
|
||||
"horizontalSync": 0.16,
|
||||
"jitter": 0.1,
|
||||
@ -571,7 +513,6 @@ QtObject{
|
||||
"fontColor": "#00ff3e",
|
||||
"fontName": "COMMODORE_PET",
|
||||
"fontWidth": 1,
|
||||
"frameName": "ROUGH_BLACK_FRAME",
|
||||
"glowingLine": 0.3,
|
||||
"horizontalSync": 0.42,
|
||||
"jitter": 0.4,
|
||||
@ -599,7 +540,6 @@ QtObject{
|
||||
"fontColor": "#ffffff",
|
||||
"fontName": "IBM_DOS",
|
||||
"fontWidth": 1,
|
||||
"frameName": "SIMPLE_WHITE_FRAME",
|
||||
"glowingLine": 0.1545,
|
||||
"horizontalSync": 0,
|
||||
"jitter": 0.1545,
|
||||
@ -627,7 +567,6 @@ QtObject{
|
||||
"fontColor": "#0ccc68",
|
||||
"fontName": "IBM_3278",
|
||||
"fontWidth": 1,
|
||||
"frameName": "SIMPLE_WHITE_FRAME",
|
||||
"glowingLine": 0,
|
||||
"horizontalSync": 0,
|
||||
"jitter": 0,
|
||||
@ -655,7 +594,6 @@ QtObject{
|
||||
"fontColor": "#729fcf",
|
||||
"fontName": "TERMINUS",
|
||||
"fontWidth": 1,
|
||||
"frameName": "NO_FRAME",
|
||||
"glowingLine": 0.1476,
|
||||
"horizontalSync": 0,
|
||||
"jitter": 0.099,
|
||||
|
62
app/qml/NewTerminalFrame.qml
Normal file
62
app/qml/NewTerminalFrame.qml
Normal file
@ -0,0 +1,62 @@
|
||||
import QtQuick 2.0
|
||||
|
||||
import "utils.js" as Utils
|
||||
|
||||
ShaderEffect {
|
||||
|
||||
property real screenCurvature: appSettings.screenCurvature * appSettings.screenCurvatureSize
|
||||
property real ambientLight: Utils.lint(0.1, 0.9, appSettings.ambientLight)
|
||||
property color frameColor: "#dedede"
|
||||
property color fontColor: appSettings.fontColor
|
||||
property color backgroundColor: appSettings.backgroundColor
|
||||
property color reflectionColor: Utils.mix(fontColor, backgroundColor, 0.2)
|
||||
|
||||
visible: screenCurvature != 0
|
||||
|
||||
fragmentShader: "
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform lowp float screenCurvature;
|
||||
uniform lowp float ambientLight;
|
||||
uniform highp float qt_Opacity;
|
||||
uniform lowp vec4 frameColor;
|
||||
uniform lowp vec4 reflectionColor;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
float max2(vec2 v) {
|
||||
return max(v.x, v.y);
|
||||
}
|
||||
|
||||
float sum2(vec2 v) {
|
||||
return v.x + v.y;
|
||||
}
|
||||
|
||||
void main(){
|
||||
vec2 staticCoords = qt_TexCoord0;
|
||||
vec2 coords = distortCoordinates(staticCoords);
|
||||
|
||||
vec3 color = mix(reflectionColor.rgb, frameColor.rgb, ambientLight);
|
||||
float dist = 0.5 * screenCurvature;
|
||||
|
||||
float shadowMask = 0.00 + max2(1.0 - smoothstep(vec2(-dist), vec2(0.0), coords) + smoothstep(vec2(1.0), vec2(1.0 + dist), coords));
|
||||
shadowMask = clamp(0.0, 1.0, shadowMask);
|
||||
color *= pow(shadowMask, 0.5);
|
||||
|
||||
float alpha = sum2(1.0 - step(0.0, coords) + step(1.0, coords));
|
||||
alpha = clamp(alpha, 0.0, 1.0) * mix(1.0, 0.9, pow(shadowMask, 0.5));
|
||||
|
||||
gl_FragColor = vec4(color * alpha, alpha);
|
||||
}
|
||||
"
|
||||
|
||||
onStatusChanged: if (log) console.log(log) //Print warning messages
|
||||
}
|
@ -39,11 +39,6 @@ Item{
|
||||
property alias title: ksession.title
|
||||
property alias kterminal: kterminal
|
||||
|
||||
anchors.leftMargin: frame.displacementLeft * appSettings.windowScaling
|
||||
anchors.rightMargin: frame.displacementRight * appSettings.windowScaling
|
||||
anchors.topMargin: frame.displacementTop * appSettings.windowScaling
|
||||
anchors.bottomMargin: frame.displacementBottom * appSettings.windowScaling
|
||||
|
||||
property size terminalSize: kterminal.terminalSize
|
||||
property size fontMetrics: kterminal.fontMetrics
|
||||
|
||||
@ -219,7 +214,7 @@ Item{
|
||||
id: kterminalSource
|
||||
sourceItem: kterminal
|
||||
hideSource: true
|
||||
wrapMode: ShaderEffectSource.ClampToEdge
|
||||
wrapMode: ShaderEffectSource.Repeat
|
||||
visible: false
|
||||
textureSize: Qt.size(kterminal.width * scaleTexture, kterminal.height * scaleTexture);
|
||||
}
|
||||
|
@ -56,17 +56,10 @@ ShaderEffect {
|
||||
|
||||
property int rasterization: appSettings.rasterization
|
||||
|
||||
property bool frameReflections: appSettings.frameReflections
|
||||
|
||||
property real disp_top: (frame.displacementTop * appSettings.windowScaling) / height
|
||||
property real disp_bottom: (frame.displacementBottom * appSettings.windowScaling) / height
|
||||
property real disp_left: (frame.displacementLeft * appSettings.windowScaling) / width
|
||||
property real disp_right: (frame.displacementRight * appSettings.windowScaling) / width
|
||||
|
||||
property real screen_brightness: Utils.lint(0.5, 1.5, appSettings.brightness)
|
||||
|
||||
property real dispX
|
||||
property real dispY
|
||||
property real ambientLight: appSettings.ambientLight * 0.2
|
||||
|
||||
property size virtual_resolution
|
||||
|
||||
property real time: timeManager.time
|
||||
@ -103,11 +96,6 @@ ShaderEffect {
|
||||
uniform highp mat4 qt_Matrix;
|
||||
uniform highp float time;
|
||||
|
||||
uniform highp float disp_left;
|
||||
uniform highp float disp_right;
|
||||
uniform highp float disp_top;
|
||||
uniform highp float disp_bottom;
|
||||
|
||||
attribute highp vec4 qt_Vertex;
|
||||
attribute highp vec2 qt_MultiTexCoord0;
|
||||
|
||||
@ -130,8 +118,7 @@ ShaderEffect {
|
||||
|
||||
"
|
||||
void main() {
|
||||
qt_TexCoord0.x = (qt_MultiTexCoord0.x - disp_left) / (1.0 - disp_left - disp_right);
|
||||
qt_TexCoord0.y = (qt_MultiTexCoord0.y - disp_top) / (1.0 - disp_top - disp_bottom);
|
||||
qt_TexCoord0 = qt_MultiTexCoord0;
|
||||
vec2 coords = vec2(fract(time/(1024.0*2.0)), fract(time/(1024.0*1024.0)));" +
|
||||
|
||||
(!fallBack && (flickering !== 0.0 || horizontalSync !== 0.0 || rbgShift !== 0) ?
|
||||
@ -168,9 +155,7 @@ ShaderEffect {
|
||||
uniform highp vec4 backgroundColor;
|
||||
uniform lowp float screen_brightness;
|
||||
|
||||
uniform highp vec2 virtual_resolution;
|
||||
uniform highp float dispX;
|
||||
uniform highp float dispY;" +
|
||||
uniform highp vec2 virtual_resolution;" +
|
||||
|
||||
(bloom !== 0 ? "
|
||||
uniform highp sampler2D bloomSource;
|
||||
@ -195,6 +180,8 @@ ShaderEffect {
|
||||
uniform lowp vec2 jitterDisplacement;" : "") +
|
||||
(rbgShift !== 0 ? "
|
||||
uniform lowp float rbgShift;" : "") +
|
||||
(ambientLight !== 0 ? "
|
||||
uniform lowp float ambientLight;" : "") +
|
||||
|
||||
(fallBack && horizontalSync !== 0 ? "
|
||||
uniform lowp float horizontalSync;" : "") +
|
||||
@ -266,7 +253,8 @@ ShaderEffect {
|
||||
|
||||
(screenCurvature !== 0 ? "
|
||||
float distortion = dot(cc, cc) * screenCurvature;
|
||||
vec2 staticCoords = (qt_TexCoord0 - cc * (1.0 + distortion) * distortion);"
|
||||
vec2 curvatureCoords = (qt_TexCoord0 - cc * (1.0 + distortion) * distortion);
|
||||
vec2 staticCoords = -curvatureCoords + vec2(2.0) * step(vec2(0.0), curvatureCoords) * curvatureCoords - vec2(2.0) * step(vec2(1.0), curvatureCoords) * curvatureCoords;"
|
||||
:"
|
||||
vec2 staticCoords = qt_TexCoord0;") +
|
||||
|
||||
@ -314,7 +302,6 @@ ShaderEffect {
|
||||
txt_color = max(txt_color, 0.5 * (txt_blur.rgb - vec3(blurDecay)));"
|
||||
: "") +
|
||||
|
||||
"txt_color *= min2(step(vec2(0.0), staticCoords) - step(vec2(1.0), staticCoords));" +
|
||||
"txt_color *= getScanlineIntensity(coords);" +
|
||||
|
||||
"txt_color += vec3(color);" +
|
||||
@ -337,12 +324,18 @@ ShaderEffect {
|
||||
"finalColor += clamp(bloomColor * bloom * bloomAlpha, 0.0, 0.5);"
|
||||
: "") +
|
||||
|
||||
"finalColor *= smoothstep(-dispX, 0.0, staticCoords.x) - smoothstep(1.0, 1.0 + dispX, staticCoords.x);
|
||||
finalColor *= smoothstep(-dispY, 0.0, staticCoords.y) - smoothstep(1.0, 1.0 + dispY, staticCoords.y);" +
|
||||
(screenCurvature !== 0 ? "
|
||||
vec2 curvatureMask = step(vec2(0.0), curvatureCoords) - step(vec2(1.0), curvatureCoords);
|
||||
finalColor *= clamp(0.0, 1.0, curvatureMask.x + curvatureMask.y);"
|
||||
:"") +
|
||||
|
||||
(flickering !== 0 ? "
|
||||
finalColor *= brightness;" : "") +
|
||||
|
||||
(ambientLight !== 0 ? "
|
||||
finalColor += vec3(ambientLight) * (1.0 - distance) * (1.0 - distance);" : "") +
|
||||
|
||||
|
||||
"gl_FragColor = vec4(finalColor * screen_brightness, qt_Opacity);" +
|
||||
"}"
|
||||
|
||||
|
@ -14,8 +14,6 @@ ShaderTerminal {
|
||||
|
||||
source: terminal.mainSource
|
||||
burnInEffect: terminal.burnInEffect
|
||||
dispX: (12 / width) * appSettings.windowScaling
|
||||
dispY: (12 / height) * appSettings.windowScaling
|
||||
virtual_resolution: terminal.virtualResolution
|
||||
|
||||
TimeManager{
|
||||
@ -23,22 +21,6 @@ ShaderTerminal {
|
||||
enableTimer: terminalWindow.visible
|
||||
}
|
||||
|
||||
Loader{
|
||||
id: frame
|
||||
anchors.fill: parent
|
||||
|
||||
property real displacementLeft: item ? item.displacementLeft : 0
|
||||
property real displacementTop: item ? item.displacementTop : 0
|
||||
property real displacementRight: item ? item.displacementRight : 0
|
||||
property real displacementBottom: item ? item.displacementBottom : 0
|
||||
|
||||
asynchronous: true
|
||||
visible: status === Loader.Ready
|
||||
|
||||
z: 2.1
|
||||
source: appSettings.frameSource
|
||||
}
|
||||
|
||||
PreprocessedTerminal{
|
||||
id: terminal
|
||||
anchors.fill: parent
|
||||
@ -74,6 +56,12 @@ ShaderTerminal {
|
||||
|
||||
bloomSource: bloomSourceLoader.item
|
||||
|
||||
NewTerminalFrame {
|
||||
id: terminalFrame
|
||||
anchors.fill: parent
|
||||
blending: true
|
||||
}
|
||||
|
||||
// This shader might be useful in the future. Since we used it only for a couple
|
||||
// of calculations is probably best to move those in the main shader. If in the future
|
||||
// we need to store another fullScreen channel this might be handy.
|
||||
|
@ -1,24 +0,0 @@
|
||||
import QtQuick 2.2
|
||||
import "utils"
|
||||
|
||||
TerminalFrame{
|
||||
id: frame
|
||||
z: 2.1
|
||||
anchors.fill: parent
|
||||
addedWidth: 200
|
||||
addedHeight: 370
|
||||
borderLeft: 170
|
||||
borderRight: 170
|
||||
borderTop: 250
|
||||
borderBottom: 250
|
||||
imageSource: "../images/black-frame.png"
|
||||
normalsSource: "../images/black-frame-normals.png"
|
||||
|
||||
displacementLeft: 80.0
|
||||
displacementTop: 65.0
|
||||
displacementRight: 80.0
|
||||
displacementBottom: 65.0
|
||||
|
||||
staticDiffuseComponent: 1.0
|
||||
dinamycDiffuseComponent: 0.6
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
import QtQuick 2.2
|
||||
import "utils"
|
||||
|
||||
TerminalFrame{
|
||||
id: frame
|
||||
z: 2.1
|
||||
anchors.fill: parent
|
||||
addedWidth: 140
|
||||
addedHeight: 140
|
||||
borderLeft: 116
|
||||
borderRight: 116
|
||||
borderTop: 116
|
||||
borderBottom: 116
|
||||
imageSource: "../images/screen-frame.png"
|
||||
normalsSource: "../images/screen-frame-normals.png"
|
||||
|
||||
displacementLeft: 55
|
||||
displacementTop: 50
|
||||
displacementRight: 55
|
||||
displacementBottom: 50
|
||||
|
||||
staticDiffuseComponent: 1.0
|
||||
dinamycDiffuseComponent: 0.6
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 1.2 MiB |
Binary file not shown.
Before Width: | Height: | Size: 1.1 MiB |
Binary file not shown.
Before Width: | Height: | Size: 1.2 MiB |
Binary file not shown.
Before Width: | Height: | Size: 498 KiB |
Binary file not shown.
Before Width: | Height: | Size: 571 KiB |
Binary file not shown.
Before Width: | Height: | Size: 811 KiB |
@ -1,219 +0,0 @@
|
||||
import QtQuick 2.2
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
import "../../utils.js" as Utils
|
||||
|
||||
Item{
|
||||
id: framecontainer
|
||||
property int textureWidth: terminalContainer.width / appSettings.windowScaling
|
||||
property int textureHeight: terminalContainer.height / appSettings.windowScaling
|
||||
|
||||
property int addedWidth
|
||||
property int addedHeight
|
||||
property int borderLeft
|
||||
property int borderRight
|
||||
property int borderTop
|
||||
property int borderBottom
|
||||
property string imageSource
|
||||
property string normalsSource
|
||||
property string shaderString
|
||||
|
||||
//Values used to displace the texture in the screen. Used to make reflections correct.
|
||||
property real displacementLeft
|
||||
property real displacementTop
|
||||
property real displacementRight
|
||||
property real displacementBottom
|
||||
|
||||
// Material coefficients
|
||||
property real staticDiffuseComponent: 0.7
|
||||
property real dinamycDiffuseComponent: 1.0
|
||||
|
||||
BorderImage{
|
||||
id: frameimage
|
||||
anchors.centerIn: parent
|
||||
width: textureWidth + addedWidth
|
||||
height: textureHeight + addedHeight
|
||||
|
||||
border.bottom: borderBottom
|
||||
border.top: borderTop
|
||||
border.left: borderLeft
|
||||
border.right: borderRight
|
||||
|
||||
source: imageSource
|
||||
horizontalTileMode: BorderImage.Stretch
|
||||
verticalTileMode: BorderImage.Stretch
|
||||
}
|
||||
BorderImage{
|
||||
id: framenormals
|
||||
anchors.fill: frameimage
|
||||
|
||||
border.bottom: borderBottom
|
||||
border.top: borderTop
|
||||
border.left: borderLeft
|
||||
border.right: borderRight
|
||||
|
||||
source: normalsSource
|
||||
horizontalTileMode: BorderImage.Stretch
|
||||
verticalTileMode: BorderImage.Stretch
|
||||
}
|
||||
ShaderEffectSource{
|
||||
id: framesource
|
||||
sourceItem: frameimage
|
||||
hideSource: true
|
||||
textureSize: Qt.size(parent.width, parent.height)
|
||||
sourceRect: Qt.rect(-1, -1, frameimage.width + 2, frameimage.height + 2)
|
||||
visible: false
|
||||
}
|
||||
ShaderEffectSource{
|
||||
id: framesourcenormals
|
||||
sourceItem: framenormals
|
||||
hideSource: true
|
||||
textureSize: Qt.size(parent.width, parent.height)
|
||||
sourceRect: Qt.rect(-1, -1, framenormals.width + 2, framenormals.height + 2)
|
||||
visible: false
|
||||
}
|
||||
|
||||
// REFLECTIONS ////////////////////////////////////////////////////////////
|
||||
Loader{
|
||||
id: reflectionEffectLoader
|
||||
width: parent.width * 0.33
|
||||
height: parent.height * 0.33
|
||||
active: appSettings.frameReflections
|
||||
|
||||
sourceComponent: FastBlur{
|
||||
id: frameReflectionEffect
|
||||
radius: 128
|
||||
source: terminal.mainSource
|
||||
smooth: false
|
||||
}
|
||||
}
|
||||
|
||||
Loader{
|
||||
id: reflectionEffectSourceLoader
|
||||
active: appSettings.frameReflections
|
||||
sourceComponent: ShaderEffectSource{
|
||||
id: frameReflectionSource
|
||||
sourceItem: reflectionEffectLoader.item
|
||||
hideSource: true
|
||||
smooth: true
|
||||
visible: false
|
||||
}
|
||||
}
|
||||
|
||||
// This texture represent the static light component.
|
||||
ShaderEffect {
|
||||
id: staticLight
|
||||
property alias source: framesource
|
||||
property alias normals: framesourcenormals
|
||||
property real screenCurvature: appSettings.screenCurvature * appSettings.screenCurvatureSize
|
||||
property size curvature_coefficients: Qt.size(width / mainShader.width, height / mainShader.height)
|
||||
property real ambientLight: appSettings.ambientLight * 0.9 + 0.1
|
||||
property color fontColor: appSettings.fontColor
|
||||
property color backgroundColor: appSettings.backgroundColor
|
||||
property color reflectionColor: Utils.mix(fontColor, backgroundColor, 0.2)
|
||||
property real diffuseComponent: staticDiffuseComponent
|
||||
|
||||
anchors.centerIn: parent
|
||||
width: parent.width + (addedWidth / textureWidth) * parent.width
|
||||
height: parent.height + (addedHeight / textureHeight) * parent.height
|
||||
|
||||
blending: true
|
||||
|
||||
fragmentShader: "
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform highp sampler2D normals;
|
||||
uniform highp sampler2D source;
|
||||
uniform lowp float screenCurvature;
|
||||
uniform highp vec2 curvature_coefficients;
|
||||
uniform lowp float ambientLight;
|
||||
uniform highp float qt_Opacity;
|
||||
uniform lowp vec4 reflectionColor;
|
||||
uniform lowp float diffuseComponent;
|
||||
|
||||
varying highp vec2 qt_TexCoord0;
|
||||
|
||||
vec2 distortCoordinates(vec2 coords){
|
||||
vec2 cc = (coords - vec2(0.5)) * curvature_coefficients;
|
||||
float dist = dot(cc, cc) * screenCurvature;
|
||||
return (coords + cc * (1.0 + dist) * dist);
|
||||
}
|
||||
|
||||
float rgb2grey(vec3 v){
|
||||
return dot(v, vec3(0.21, 0.72, 0.04));
|
||||
}
|
||||
|
||||
void main(){
|
||||
vec2 coords = distortCoordinates(qt_TexCoord0);
|
||||
vec4 txtColor = texture2D(source, coords);
|
||||
vec4 txtNormal = texture2D(normals, coords);
|
||||
|
||||
vec3 normal = normalize(txtNormal.rgb * 2.0 - 1.0);
|
||||
vec2 lightDirection = normalize(vec2(0.5, 0.5) - coords);
|
||||
float dotProd = dot(normal, vec3(lightDirection, 0.0)) * diffuseComponent * txtNormal.a;
|
||||
|
||||
vec3 darkColor = dotProd * reflectionColor.rgb;
|
||||
gl_FragColor = vec4(mix(darkColor, txtColor.rgb, ambientLight), dotProd);
|
||||
}
|
||||
"
|
||||
|
||||
onStatusChanged: if (log) console.log(log) //Print warning messages
|
||||
}
|
||||
|
||||
ShaderEffectSource {
|
||||
id: staticLightSource
|
||||
sourceItem: staticLight
|
||||
hideSource: true
|
||||
anchors.fill: staticLight
|
||||
live: true
|
||||
}
|
||||
|
||||
Loader{
|
||||
id: dynamicLightLoader
|
||||
anchors.fill: staticLight
|
||||
active: appSettings.frameReflections
|
||||
sourceComponent: ShaderEffect {
|
||||
property ShaderEffectSource lightMask: staticLightSource
|
||||
property ShaderEffectSource reflectionSource: reflectionEffectSourceLoader.item
|
||||
property real diffuseComponent: dinamycDiffuseComponent
|
||||
property real chromaColor: appSettings.chromaColor
|
||||
property color fontColor: appSettings.fontColor
|
||||
|
||||
visible: true
|
||||
blending: true
|
||||
|
||||
fragmentShader: "
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform sampler2D lightMask;
|
||||
uniform sampler2D reflectionSource;
|
||||
uniform lowp float diffuseComponent;
|
||||
uniform lowp float chromaColor;
|
||||
uniform highp vec4 fontColor;
|
||||
uniform highp float qt_Opacity;
|
||||
|
||||
varying highp vec2 qt_TexCoord0;
|
||||
|
||||
float rgb2grey(vec3 v){
|
||||
return dot(v, vec3(0.21, 0.72, 0.04));
|
||||
}
|
||||
|
||||
void main() {
|
||||
float alpha = texture2D(lightMask, qt_TexCoord0).a * diffuseComponent;
|
||||
vec3 reflectionColor = texture2D(reflectionSource, qt_TexCoord0).rgb;
|
||||
vec3 color = fontColor.rgb * rgb2grey(reflectionColor);" +
|
||||
(chromaColor !== 0 ?
|
||||
"color = mix(color, fontColor.rgb * reflectionColor, chromaColor);"
|
||||
: "") +
|
||||
"gl_FragColor = vec4(color, 1.0) * alpha;
|
||||
}
|
||||
"
|
||||
|
||||
onStatusChanged: if (log) console.log(log) //Print warning messages
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>frames/BlackRoughFrame.qml</file>
|
||||
<file>frames/images/black-frame.png</file>
|
||||
<file>frames/images/screen-frame-normals.png</file>
|
||||
<file>frames/images/black-frame-normals.png</file>
|
||||
<file>frames/images/screen-frame.png</file>
|
||||
<file>frames/images/black-frame-original.png</file>
|
||||
<file>frames/images/screen-frame-original.png</file>
|
||||
<file>frames/WhiteSimpleFrame.qml</file>
|
||||
<file>frames/utils/TerminalFrame.qml</file>
|
||||
<file>SizeOverlay.qml</file>
|
||||
<file>ShaderTerminal.qml</file>
|
||||
<file>CheckableSlider.qml</file>
|
||||
@ -52,5 +43,6 @@
|
||||
<file>fonts/1977-commodore-pet/PetMe.ttf</file>
|
||||
<file>BurnInEffect.qml</file>
|
||||
<file>fonts/modern-terminus/TerminusTTF-4.46.0.ttf</file>
|
||||
<file>NewTerminalFrame.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
x
Reference in New Issue
Block a user