From 6832b32741662e2d9b9189718ecb1ed9792f79e6 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Sat, 20 Dec 2014 18:33:31 +0100 Subject: [PATCH] Fix: screen curvature is now consistent across all screen sizes. Close #176. --- app/qml/frames/BlackRoughFrame.qml | 2 -- app/qml/frames/WhiteSimpleFrame.qml | 2 -- app/qml/frames/utils/TerminalFrame.qml | 12 ++++++------ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/qml/frames/BlackRoughFrame.qml b/app/qml/frames/BlackRoughFrame.qml index ebe0708..1503049 100644 --- a/app/qml/frames/BlackRoughFrame.qml +++ b/app/qml/frames/BlackRoughFrame.qml @@ -14,8 +14,6 @@ TerminalFrame{ imageSource: "../images/black-frame.png" normalsSource: "../images/black-frame-normals.png" - distortionCoefficient: 1.9 - displacementLeft: 80.0 displacementTop: 65.0 displacementRight: 80.0 diff --git a/app/qml/frames/WhiteSimpleFrame.qml b/app/qml/frames/WhiteSimpleFrame.qml index 77a42fe..84d85a2 100644 --- a/app/qml/frames/WhiteSimpleFrame.qml +++ b/app/qml/frames/WhiteSimpleFrame.qml @@ -14,8 +14,6 @@ TerminalFrame{ imageSource: "../images/screen-frame.png" normalsSource: "../images/screen-frame-normals.png" - distortionCoefficient: 1.5 - displacementLeft: 55 displacementTop: 50 displacementRight: 55 diff --git a/app/qml/frames/utils/TerminalFrame.qml b/app/qml/frames/utils/TerminalFrame.qml index 2b9869f..2b17147 100644 --- a/app/qml/frames/utils/TerminalFrame.qml +++ b/app/qml/frames/utils/TerminalFrame.qml @@ -5,8 +5,8 @@ import "../../utils.js" as Utils Item{ id: framecontainer - property int textureWidth: terminalWindow.width - property int textureHeight: terminalWindow.height + property int textureWidth: terminalContainer.width + property int textureHeight: terminalContainer.height property int addedWidth property int addedHeight @@ -28,8 +28,6 @@ Item{ property real staticDiffuseComponent: 0.7 property real dinamycDiffuseComponent: 1.0 - property real distortionCoefficient - BorderImage{ id: frameimage anchors.centerIn: parent @@ -105,7 +103,8 @@ Item{ id: staticLight property alias source: framesource property alias normals: framesourcenormals - property real screen_distorsion: appSettings.screen_distortion * framecontainer.distortionCoefficient + property real screen_distorsion: appSettings.screen_distortion + property size curvature_coefficients: Qt.size(width / mainShader.width, height / mainShader.height) property real ambient_light: appSettings.ambient_light property color font_color: appSettings.font_color property color background_color: appSettings.background_color @@ -122,6 +121,7 @@ Item{ uniform highp sampler2D normals; uniform highp sampler2D source; uniform lowp float screen_distorsion; + uniform highp vec2 curvature_coefficients; uniform lowp float ambient_light; uniform highp float qt_Opacity; uniform lowp vec4 reflectionColor; @@ -130,7 +130,7 @@ Item{ varying highp vec2 qt_TexCoord0; vec2 distortCoordinates(vec2 coords){ - vec2 cc = coords - vec2(0.5); + vec2 cc = (coords - vec2(0.5)) * curvature_coefficients; float dist = dot(cc, cc) * screen_distorsion; return (coords + cc * (1.0 + dist) * dist); }