diff --git a/app/frames/BlackRoughFrame.qml b/app/frames/BlackRoughFrame.qml index 6b6ca10..211cb97 100644 --- a/app/frames/BlackRoughFrame.qml +++ b/app/frames/BlackRoughFrame.qml @@ -16,5 +16,5 @@ TerminalFrame{ normalsSource: "../images/black-frame-normals.png" sourceRect: Qt.rect(-80, -90, terminal.width + 160, terminal.height + 180) - shaderString: "WhiteFrameShader.qml" + shaderString: "FrameShader.qml" } diff --git a/app/frames/NoFrame.qml b/app/frames/NoFrame.qml index de48a1c..5cbf386 100644 --- a/app/frames/NoFrame.qml +++ b/app/frames/NoFrame.qml @@ -5,8 +5,8 @@ TerminalFrame{ id: frame z: 2.1 anchors.fill: parent - addedWidth: 190 - addedHeight: 190 + addedWidth: 140 + addedHeight: 140 borderLeft: 116 borderRight: 116 borderTop: 116 diff --git a/app/frames/WhiteSimpleFrame.qml b/app/frames/WhiteSimpleFrame.qml index f899dd7..085052c 100644 --- a/app/frames/WhiteSimpleFrame.qml +++ b/app/frames/WhiteSimpleFrame.qml @@ -12,8 +12,8 @@ TerminalFrame{ borderTop: 116 borderBottom: 116 imageSource: "../images/screen-frame.png" - //normalsSource: "../images/screen-frame-normals.png" + normalsSource: "../images/screen-frame-normals.png" sourceRect: Qt.rect(-65, -75, terminal.width + 130, terminal.height + 150) - shaderString: "WhiteFrameShader.qml" + shaderString: "FrameShader.qml" } diff --git a/app/frames/images/black-frame-normals.png b/app/frames/images/black-frame-normals.png index f033e46..70bb73f 100644 Binary files a/app/frames/images/black-frame-normals.png and b/app/frames/images/black-frame-normals.png differ diff --git a/app/frames/images/screen-frame-normals.png b/app/frames/images/screen-frame-normals.png index 41410b4..2d7e955 100644 Binary files a/app/frames/images/screen-frame-normals.png and b/app/frames/images/screen-frame-normals.png differ diff --git a/app/frames/utils/FrameShader.qml b/app/frames/utils/FrameShader.qml new file mode 100644 index 0000000..1fa58e7 --- /dev/null +++ b/app/frames/utils/FrameShader.qml @@ -0,0 +1,46 @@ +import QtQuick 2.1 + +ShaderEffect{ + property variant source: framesource + property variant normals: framesourcenormals + property real screen_distorsion: shadersettings.screen_distortion + 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 + + property color reflection_color: Qt.rgba((font_color.r*0.3 + background_color.r*0.7), + (font_color.g*0.3 + background_color.g*0.7), + (font_color.b*0.3 + background_color.b*0.7), + 1.0) + + + fragmentShader: " + uniform sampler2D source; + uniform sampler2D normals; + uniform highp float screen_distorsion; + uniform highp float ambient_light; + + uniform vec4 reflection_color; + uniform highp float brightness; + + varying highp vec2 qt_TexCoord0; + + vec2 distortCoordinates(vec2 coords){ + vec2 cc = coords - vec2(0.5); + float dist = dot(cc, cc) * screen_distorsion; + return (coords + cc * (1.0 + dist) * dist); + } + + void main(){ + vec2 coords = distortCoordinates(qt_TexCoord0); + vec4 txt_color = texture2D(source, coords); + vec4 txt_normal = texture2D(normals, coords); + vec3 normal = normalize(txt_normal.rgb * 2.0 - 1.0); + vec3 light_dir = normalize(vec3(0.5,0.5, 0.0) - vec3(qt_TexCoord0, 0.0)); + float reflection = dot(normal, light_dir) * 0.4 * brightness + 0.2; + vec3 final_color = reflection_color * reflection * 0.5; + final_color += txt_color * ambient_light; + gl_FragColor = vec4(final_color * txt_normal.a, txt_color.a); + }" +} diff --git a/app/frames/utils/TerminalFrame.qml b/app/frames/utils/TerminalFrame.qml index 4d26ca9..c2fedf4 100644 --- a/app/frames/utils/TerminalFrame.qml +++ b/app/frames/utils/TerminalFrame.qml @@ -46,11 +46,11 @@ Item{ sourceItem: frameimage hideSource: true } -// ShaderEffectSource{ -// id: framesourcenormals -// sourceItem: framenormals -// hideSource: true -// } + ShaderEffectSource{ + id: framesourcenormals + sourceItem: framenormals + hideSource: true + } Loader{ anchors.fill: frameimage source: shaderString diff --git a/app/frames/utils/WhiteFrameShader.qml b/app/frames/utils/WhiteFrameShader.qml deleted file mode 100644 index 58fb85c..0000000 --- a/app/frames/utils/WhiteFrameShader.qml +++ /dev/null @@ -1,65 +0,0 @@ -import QtQuick 2.1 - -ShaderEffect{ - property variant source: framesource - //property variant normals: framesourcenormals - property real screen_distorsion: shadersettings.screen_distortion - 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: " -// uniform sampler2D source; -// uniform sampler2D normals; -// uniform highp float screen_distorsion; -// uniform highp float ambient_light; - -// uniform highp vec4 font_color; -// uniform highp vec4 background_color; -// uniform highp float brightness; - -// varying highp vec2 qt_TexCoord0; - -// vec2 distortCoordinates(vec2 coords){ -// vec2 cc = coords - vec2(0.5); -// float dist = dot(cc, cc) * screen_distorsion; -// return (coords + cc * (1.0 + dist) * dist); -// } - -// void main(){ -// vec2 coords = distortCoordinates(qt_TexCoord0); -// vec4 txt_color = texture2D(source, coords); -// vec4 normala = texture2D(normals, coords); -// vec3 normal = normalize(normala.rgb) * txt_color.a; -// float reflection = dot(normal, vec3(1.0, 1.0, 0.0)) * 0.4 * 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); -// }" - - fragmentShader: " - uniform sampler2D source; - uniform highp float screen_distorsion; - uniform highp float ambient_light; - - uniform highp vec4 font_color; - uniform highp vec4 background_color; - uniform highp float brightness; - - varying highp vec2 qt_TexCoord0; - - vec2 distortCoordinates(vec2 coords){ - vec2 cc = coords - vec2(0.5); - float dist = dot(cc, cc) * screen_distorsion; - return (coords + cc * (1.0 + dist) * dist); - } - - void main(){ - vec2 coords = distortCoordinates(qt_TexCoord0); - vec4 txt_color = texture2D(source, coords); - vec3 reflection_color = mix(font_color, background_color, 0.7).rgb * 0.2 * brightness; - vec3 final_color = mix(txt_color.rgb, reflection_color, 1.0 - ambient_light); - gl_FragColor = vec4(final_color, txt_color.a); - }" -}